|
Boost Users : |
From: David Greene (greened_at_[hidden])
Date: 2006-02-20 19:34:03
David Greene wrote:
> If I have an asynchronous state machine running in another thread and
> I send it an event, is there any way to have the sending thread block
> until the event is processed? I need to use an asynchoronous machine
> because the rest of my app is threaded but yet there are points where
> I must synchronize to know the machine is in a certain state before
> moving on.
>
> From the documentation it seems like passing zero to
> FifoWorker::operator() (via fifo_scheduler::operator()) will do the
> trick, but I'm not sure.
>
> I've created a non-blocking asynchronous machine because the
> thread calling fifo_scheduler::operator() should not block if
> the queue is empty. It should process all events in the queue
> and return.
>
> Have I got that all correct?
Quick follow-up: when the documentation says that FifoWorker::operator()
"must only be called from exactly one thread," does that mean it must
be called only from one thread at any given time (i.e. it must be
protected with mutexes or other concurrency protection) or that
literally only one thread may ever call it and it must always be the
same thread that calls it?
If it's the latter then that changes things quite dramatically and I
probably want a blocking scheduler and will need to create another
thread just to wait on empty and call operator() when full.
-Dave
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