Re: [Boost-users] [statechart] handling unexpected events

On 2008-09-18 20:54:11 GMT, Robert wrote:
The only thing I can see is that the unconsumed_event() function is called with the unexpected event object. What I'd like to do in this function is:
1. Abort my transaction and force the state machine back to the Ready state. I'm not sure how to do this.
I've implemented a hack with an internal event, ResetEvent, that I post. This sort of works, but it executes the exit() member function of the aborted state. I'd rather not, I'm trying to abort the behavior of the current state, not complete it. If there was a way from unconsumed_event() to get the current state object and set a flag in it, I could avoid completing the state behavior with a guard. I can use state_downcast<const T *>() to get a const pointer to my state object, but because it is const I can't set a flag. I cannot seem to get a non-const pointer.
2. Reprocess the unexpected event if it is a hello or get, discard it otherwise. I'm not sure how to do this, either.
I've discovered that post_event() will enqueue any event for processing after the current react() is finished. Thanks for any insight you can provide, -- Robert

From: Andreas Huber <ahd6974-spamboostorgtrap@yahoo.com> Subject: RE: [Boost-users] [statechart] handling unexpected events To: "Robert Mecklenburg" <rmecklenburg@s5w.com> Date: Monday, September 22, 2008, 11:31 PM
Hi Robert
If you really do not want to have the data_delivered::exit() function called when an unknown event occurs then your best option is to define the following reactions for data_delivered:
1. An ordinary transition to then ready state, triggered by the commit event 2. An ordinary transition to the ready state, triggered by exception_thrown event 3. An in_state_reaction triggered by even_base, which first posts the event an then throws an exception
Note: The order of the reactions is relevant.
HTH,
Andreas
-- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
participants (2)
-
Andreas Huber
-
Robert Mecklenburg