Boost logo

Boost :

Subject: Re: [boost] [MSM] Interrupt anonymous transitions or blocking process_events?
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2011-04-22 07:00:29


Hi Mathias,

> Hi Christophe,
>
> Thank you for the helpful reply!

You're welcome :)

> That helped me alot doing it that way. Thank you! It was a struggle
> before I realized how to call a process_event(...) from within a member
> function. I hope I am doing it the right way :-)
>
> I also tried adding
>
> boost::signals2::signal<void ()> sig;
>
> to the statemachine but my compiler did not like that at all
> (noncopyable errors). So I stayed with a mutex and a condition variable.
> The way I did it can be improved I am sure...
>
> Anyway, you can see an outline below of how I did this. Perhaps this is
> an ok way doing it?

<snip>

Depending on how you use it, yes. I'm a bit worried with race
conditions in case your state machine is also used in another thread,
which would also call process_event.

Alternatively (if you want to avoid locking/deadlocking/rc), you could
also move the worker thread out of the fsm and have both communicate
with synchronized message queues. You might want to have a look at
boost::circular_buffer, which provides an example
(http://www.boost.org/doc/libs/1_46_1/libs/circular_buffer/doc/circular_buffer.html#boundedbuffer).

Regards,
Christophe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk