Hi libusbx-devel, I'd like to write an application which uses the "simple" async approach. I can't use the polled approach because I'd like my code to be portable to Windows.
Here's a scenario: The main thread creates the worker thread, which calls one of the libusb_handle_events_*() varients in a loop, ready to start handling completion events triggered by user actions. Ordinarily, the main thread would submit some requests to be handled by callbacks on the worker thread, but in this case the user merely asks for the app to shutdown immediately after startup. Therefore no requests are submitted, and the worker thread continues to block until the libusb_handle_events() timeout. In this scenario, what is the best way for the main thread to ask the worker thread to shutdown cleanly? It looks like I can call libusb_unlock_event_waiters() to force libusb_handle_events() to exit, but then I'd need a suitably-mutexed variable as a condition on the loop, and I start to get the feeling I'm doing something wrong. Alternatively, perhaps I must ensure the worker only enters libusb_handle_events() when it's sure there are outstanding requests, and I'm back to condition variables and I get that "I'm doing it wrong" feeling again. Any advice? Chris ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel