Boost logo

Boost Users :

From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2007-09-08 05:47:28


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. 

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net