|
Boost : |
Subject: Re: [boost] [MSM] Interrupt anonymous transitions or blocking process_events?
From: anlmat (anlmat_at_[hidden])
Date: 2011-04-22 16:17:01
Hi Christophe,
>> 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.
Yes, I protect every call to process_event with a mutex. Since I don't
have that many events I have created a member function that wraps and
protects the process_event call. (One member function per 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).
Yes, that is an interesting idea. But how do you solve the problem with
passing events on to the message queue? The events are all of different
types. Do you mean that there should be some parsing of strings or some
other identifier?
Regards,
Mathias
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk