Fundamental API question - threads or polls

C, C++, and Visual C++
Post Reply
relavak
Fresh meat
Posts: 1
Joined: Wed Sep 12, 2018 2:53 pm
Contact:

Fundamental API question - threads or polls

Post by relavak »

It is unclear from the documentation how the phidget22 library handles synchronization between a main loop and the phidget operations. Does the library use a separate thread or multiple threads? If so, how do I synchronize my main loop with the library to avoid race conditions (i.e. what are the design rules and api related to locking). If not a thread, when are phidget operations such as attach and detach called?

One other issue is that sometimes my calls to setdutycycle fail with the error code "unexpected". This doesn't seem to invoke the detach but subsequent calls to setdutycycle also fail and forcing an attach seems to cause a bunch of detach/attach cycles that eventually look like they cause massive failure. The error handler also does not seem to be called.
User avatar
Patrick
Lead Developer
Posts: 3403
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Fundamental API question - threads or polls

Post by Patrick »

The Phidget API is fully thread-safe.

Event are called from a pool of threads, it is up to the user to synchronize event calls.

Call into the library are mostly synchronous. The exceptions are open() (without the timeout) and the _async() versions of some set functions.


Can you provide some more info about your failure case:
Are you using the latest library?
What hardware are you using?
Please provide a library log of the failure at INFO level.

-Patrick
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests