Timer and thread support #60
-
First of all, thanks for this wonderful project!
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
My pleasure, glad you like it! TimersIn general, HFSM2 and FFSM2 focus only on state transitions, and provide the tools for the user to implement the supporting infrastructure, be those timers or threads. For examples of event handling please see:
It boils down to adding struct TimerEvent {}; // can be any type, even bool / char / int / etc.
struct ConcreteHandler
: FSM::State
{
// handle two event types - PrimaryEvent
void react(const TimerEvent&, FullControl&) {
// implement
}
// if you have more than one event but only handle one in this state, be sure to add this line:
using FSM::State::react;
}; .. and triggering it from your timer callback: // ..
FSM::Instance machine;
// ..
void TimerProc(..) {
machine.react(TimerEvent{});
} One thing to be mindful of, is E.g. in my UE4 toy project, I needed to trigger delegates in states' Thread safety (or the lack thereof)HFSM2 isn't thread safe. |
Beta Was this translation helpful? Give feedback.
My pleasure, glad you like it!
Timers
In general, HFSM2 and FFSM2 focus only on state transitions, and provide the tools for the user to implement the supporting infrastructure, be those timers or threads.
For examples of event handling please see:
It boils down to adding
react(const TimerEvent&, FullControl&)
method to the state, that's expected to handle it: