[linux-audio-dev] A "best" event delegation strategy?
AFBLukas at gmx.de
Fri May 30 07:51:01 UTC 2003
Here is a propblem that is propably already solved in another context,
so i would like to know some opinions on it:
I am trying to implement a (hopefully:-) ) simple general-purpose event
The actual application will propably be something like a network of
modules that can do arbitrary filtering, generation and manipulation of
midi events in real time.
As propably different kinds of external event sources, like several midi
ports, maybe joystick device and of course a gui, are involved, how
would one efficiently organize the delegation of events passed between
the modules, so that the everything is still thread-safe?
The three main ideas i can currently think of are:
A: don't do it at all, that is, everything is implemented as simple
subject/observer patterns, so that the communication is a pure
Mutexes et al, would have to be managed by each individual plugin.
B: use a global, mutexed event queue. This could be a priority queue for
time-stamped events, or a simple FIFO.
C: use local queues. As above, but for each individual module.
Each of the above aproaches seems to have its advantages and
disatvantages. E.g. if queues are used, this would as far as i an judge,
make it easy to have feedback cycles.
OTOH this would propably introduce some overhead which aproach A
wouldn't have. C would propably involve a single thread for each module,
or a global "clock" thread that periodicaly calls an "process_queue"
method on each module.
Is there a general "best" way to do this?
More information about the Linux-audio-dev