Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2907: Events no longer reach orthogonal inner state after leaving that state and then returning to it
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-04-03 16:01:58
#2907: Events no longer reach orthogonal inner state after leaving that state and
then returning to it
---------------------------------------------------------------------------+
Reporter: George van Venrooij <george.van.venrooij_at_[hidden]> | Owner: andreas_huber69
Type: Bugs | Status: closed
Milestone: To Be Determined | Component: statechart
Version: Boost 1.37.0 | Severity: Problem
Resolution: invalid | Keywords: event fowarding orthogonal inner state
---------------------------------------------------------------------------+
Changes (by andreas_huber69):
* status: new => closed
* resolution: => invalid
Comment:
The observed behavior stems from a documented limitation of
Boost.Statechart:
<http://www.boost.org/doc/libs/1_38_0/libs/statechart/doc/rationale.html#Limitations>
(see subsection "Event dispatch to orthogonal regions")
For a precise but possibly hard to read description of the event dispatch
algorithm, please see:
<http://www.boost.org/doc/libs/1_38_0/libs/statechart/doc/reference.html#process_event>
In a nutshell, the event dispatch algorithm does the following for each
event:
1. Starts a new reaction search.
2. Selects an *arbitrary* but in this reaction search not yet visited
state from all the currently active innermost states. If no such state
exists then reaction search is considered unsuccessful.
3. If the current state or any of its outer states has a suitable reaction
for the event, the event is dispatched. Reactions defined in inner states
take precedence over reactions of the outer states. If no suitable
reaction has been found then reaction search resumes with step 2.
Note that reactions defined in outer states are checked *before* reactions
defined in other innermost states.
To explain things in your example:
- In steps 1-3, before the event is dispatched, state_1A is the first
innermost state that is selected. So, for all events this state and its
outer state are first checked for a suitale reaction.
- In steps 4-6, before the event is dispatched, state_2A is the first
innermost state that is selected. So, for all events this state and its
outer state are first checked for a suitale reaction.
In step 2, state_1A does have a reaction for update_event, so it is
selected.
In step 6, state_2A does not have a reaction for update_event so the
reaction of its outer state (parent_state) is selected. Consequently, if
you remove the update_event reaction in parent_state then everything
should work as expected.
(Note that the documentation says that the order in which the innermost
states are selected during reaction search is arbitrary, so you should not
write code that depends on the selection order.)
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2907#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC