Boost logo

Boost Users :

Subject: [Boost-users] [statechart] process_event vs post_event confusion
From: Robert Dailey (rcdailey.lists_at_[hidden])
Date: 2017-03-29 15:06:59


I'm seeing a usability issue between post_event and process_event.
Basically, depending on where in the state itself I'm executing an
event, I need to know which to invoke. My understanding is that if I'm
calling within the context of the constructor of the state, I need to
use post_event. Anywhere else (outside of construction, but still
within a member function of the state subclass itself), you invoke
"context<MyMachine>().process_event()".

Why can't post_event() automatically query the state machine to see if
it is "busy" constructing a state, and if it isn't, forward the event
to process_event() for me instead? Is there really a reason to have to
make a logical decision between the two in code?

I'm using boost::statechart in my code at $DAYJOB and this is a
reasonable complaint I get in my code reviews, especially from those
not very familiar with boost itself. They have an expectation for the
implementation of the state machine to be intuitive and easy to
understand.


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