Boost logo

Boost Users :

Subject: Re: [Boost-users] [MSM] state transitions and exceptions
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2012-04-06 15:45:23


<snip>
>When there is an error in the outermost statemachine we propagate the
>exception out from it. At this point, the client code (which calls
>the process_event function) shall restart the state machine therefore
>resetting it to the initial state. But we cannot simply restart the
>machine because after we have thrown the exception out from it, it
>becomes nonresponsive, i.e. it does not react to the fsm->stop() and
>fsm->start() sequence.
>
>So we came up with the following:
>
>void Client::reCreateBackEnd()
>{
>if(backEnd){ // backEnd is a smart pointer
>backEnd->stop();
>backEnd.reset();
>}
>
>// Constructing the BackEnd
>backEnd.reset(new ...);
>backEnd->set_states( ... );
>backEnd->start();
>}
>
>It is too drastic to recreate the back end, I think. Christophe, is
>there any more elegant solution to do this? Why is it that the state
>machine becomes not restartable if an exception is thrown out from it?
>
>BR,
>Gabor

Which version are you using? Until 1.49, it was not possible to call start()
a second time. I think your machine probably stayed in the state it was
before the exception.
If I understood your problem, it should be gone with 1.49.

HTH,
Christophe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net