I have two statecharts (FSM_A and FSM_B) implemented using boost::statechart.
Is it safe to process an event from FSM_A in order to trigger a transition in FSM_B?
Should I use two async_state_machine? Or maybe a common outermost state?
Here is an example:
struct FSM_B;
struct FSM_A : sc::state_machine<FSM_A, InitialStateA>
{
FSM_B* pB;
};
struct FSM_B : sc::state_machine<FSM_B, InitialStateB>
{};
struct InitialStateB : sc::simple_state<InitialStateB, FSM_B>
{
typedef sc::transition< EV_CrossEvent, InitialStateB > rections;
};
struct InitialStateA : sc::simple_state<InitialStateA, FSM_A>
{
InitialStateA()
{
context<FSM_A>().pB->process_event( EV_CrossEvent() );
}
};
int main()
{
FSM_B b;
FSM_A a;
a.pB = &b;
a.initiate();
b.initiate();
return 0;
}