[PD-dev] supporting multiple instances reading one device

Hans-Christoph Steiner hans at eds.org
Fri Feb 3 23:31:49 CET 2006


I would like to make it so that multiple instances of the [hid] object  
can read from the same device.  Right now, this is kind of supported,  
but its buggy and behaves badly.  Each [hid] instance now reads from  
the device queue, therefore each instance is stealing events that the  
other instances won't ever see.  Not good.

So I want to run my current idea for handling this by y'all to see if  
it makes sense. The first instance that is turned on reads the event  
queue, sticks the events in array, then outputs the data from that  
array.  Then every other instance just outputs from that array.

The first question I have is when does the reader instance know when  
that message cycle is over and it can destroy the previous array?  If I  
just keep each array for two cycles, then destroy it, that should work,  
right?

The second question is how to "elect" a new reader instance when the  
current one is deleted, turned off, whatever.  I am thinking of just  
having a "no_reader" flag that the reader instance would flip when it  
stops.  Then the next instance to try to output data would be make  
itself the reader.  Any possible problems with that approach?

.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





More information about the Pd-dev mailing list