I am thinking of making a worker thread for the [hid] stuff which would monitor the queue, then call a callback for each instance of [hid] that wants data from that queue. This would allow [hid] to easily and properly support multiple instances that access the same device.
Also, I am thinking of a similar setup for multicast-DNS (aka Zeroconf aka Bonjour aka Rendezvous) objects that I am working on.
Are there any objects that currently work like this that I can use as examples? Any pitfalls to this approach?
.hc
________________________________________________________________________ ____
"[W]e have invented the technology to eliminate scarcity, but we are deliberately throwing it away to benefit those who profit from scarcity." -John Gilmore
On Feb 2, 2006, at 3:06 AM, Georg Holzmann wrote:
Hallo!
Are there any objects that currently work like this that I can use as examples?
the objects in threadlib, or sndfiler
As far as I understand it, those are structured differently. Don't they spawn a thread when you give it an open command, and then object waits for the thread to return, after which, that thread dies?
I am thinking of having one "worker" thread which listens for events then calls the output function for each instance of [hid]. So there would only be one worker thread per device, no matter how many instances of [hid] were accessing that device.
.hc ________________________________________________________________________ ____
"Terrorism is not an enemy. It cannot be defeated. It's a tactic. It's about as sensible to say we declare war on night attacks and expect we're going to win that war. We're not going to win the war on terrorism." - retired U.S. Army general, William Odom
Hallo!
the objects in threadlib, or sndfiler
I am thinking of having one "worker" thread which listens for events then calls the output function for each instance of [hid]. So there would only be one worker thread per device, no matter how many instances of [hid] were accessing that device.
yes, [sndfiler] has also only one worker thread ... (see externals/tb/sndfiler/src/sndfiler.c)
You can register a function in a FIFO (fifo_put), and this function will be called from the worker thread, then you can use sys_callback to synchronize with pd's main thread.
LG Georg