Re: [boost] [MSM] Interrupt anonymous transitions or blocking process_events?

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_buffe...). Regards, Christophe

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_buffe...).
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
participants (2)
-
anlmat
-
Christophe Henry