[statechart] managing large collection of async statemachines.
Hello, I have to instantiate a large collection (1200) of asynchronous statemachines which obviously can not have their own thread of execution. My basic idea was to spawn a collection of threads with 1 scheduler per thread (inline with the tutorial) and then create several processors ie statemachines per scheduler. This seems to work however there's 1 aspect which I can not solve. When queueing an event I have to distribute now the events to the right async statemachine based on a simple id which each event carries. Problem seems the access to the statemachine (I need the id obviously) since I only have a (collection of) processor handles. How can this be done? Kind regards, John.
Hi John
I have to instantiate a large collection (1200) of asynchronous statemachines which obviously can not have their own thread of execution.
My basic idea was to spawn a collection of threads with 1 scheduler per thread (inline with the tutorial) and then create several processors ie statemachines per scheduler. This seems to work however there's 1 aspect which I can not solve. When queueing an event I have to distribute now the events to the right async statemachine based on a simple id which each event carries. Problem seems the access to the statemachine (I need the id obviously) since I only have a (collection of) processor handles. How can this be done?
I would suggest the implementation of a "demultiplexer" event processor. An object of this class is created before any other event processor. The handle and scheduler of this processor are then passed as constructor arguments to all the state machines, which register themselves with the demultiplexer during creation (and deregister during destruction). All events are then sent to the demultiplexer, which will pass them on to the correct state machine. This design of course assumes that the processor hosting the demultiplexer is fast enough to handle all the events. HTH, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
participants (2)
-
Andreas Huber
-
Johan Kuijpers