-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS hid.c created a separate thread for runloop #321
Comments
HIDAPI needs a runloop to function. A runloop blocks the thread execution where it is invoked, and only processes "asyncronous" messages sent to objects that "live" in that runloop. Each macOS HID object has to live in a runloop as it is the only way to get HID interruptions (maybe some more, can't recall at the moment). In theory - yes, HIDAPI could leave without a separate thread, but only if a calling code guarantees that in each thread where This makes a limitation on the usage of the HIDAPI, and makes it really hard to use HIDAPI in simple UNIX-like console application, which knows nothing of the environment they run in (macOS)/runloops/etc. |
What is done right now - a thread is created per-device. |
I’m currently working on the macOS port for HIDPP and my understanding is that, in the case of HIDPP all interaction with the device is blocking, and not asynchronous. That’s why it was unnecessary to create a separate thread to run the runLoop on. As soon as you want any asynchronous interaction with the device like having a |
Close this as it is answered. |
Ref: cvuchener/hidpp#17 (comment)
cvuchener (author of hidpp) seems to say this may not be a necessary and he thinks there is a potentially better way to use mach ports.
I do not understand this well. Just wondering why the macOS codes create a seperate thread for runloop.
The text was updated successfully, but these errors were encountered: