[MSM] What happens to MSM if guard returns `false`, mutable events and error recovery?
Hi,
I am currently reading through the MSM docs and have one question, what happens to MSM if guard returns `false`. Does the MSM enter an error state in orthogonal region (http://www.boost.org/doc/libs/1_64_0/libs/msm/doc/HTML/ch03s02.html#d0e577)?
Even internals page describes, what happens if guard returns `true`, but not a single word on `false` case.
What happens is described in http://www.boost.org/doc/libs/1_64_0/libs/msm/doc/HTML/ch02s02.html#d0e226 and in http://www.boost.org/doc/libs/1_64_0/libs/msm/doc/HTML/ch06.html#d0e3013 To sum up, in this case the next guard is tried and the next until no more is left. If all return false, processing in this region is finished. Each region processes independently from others but if one guard rejected the event, this event is seen as processed.
Regarding the const events: I am programming an MSM to proxy network traffic and once a message with data was received it'll be analysed and moved between different states. Message instances implement move semantics. Currently, the MSM has an initial state `ready` where the `message_in` event is handled. This event contains the message to be analysed. From my current understanding I either have to make message field in `message_in` event mutable or MSM needs to to support r-value references. Can somebody tell me what's going to happen if the action only accepts r-value reference to an event instance? Currently, it seems to work, but would like to understand the implications.
MSM is still C++98. const& were necessary to pass temporary objects. You can simply const_cast. I'm unsure about the r-value reference action.
My last question relates to multi-threading. I understand that MSM manages internal states, would it be safe to create MSM as a thread-local storage and restart the thread-local MSM if the new request comes in? It's more about, what happens to MSM after an error state? Is calling stop(), start() members enough?
I don't get where there is multithreading in your question. Using TLS it is thread-safe to restart whatever you want. start() calls the first on_entry, stop(), the last on_exit, nothing else. HTH, Christophe
participants (1)
-
Christophe Henry