Special task which executes as finite state machine.
To implement a task that will be executed using FSM you need to declare its class like this:
class CMyClass : public CSrvStatesTask<CMyClass>
All machine states are referenced via pointer to function implementing this state. To make state referencing more convenient there's a typedef Me pointing to your class (CMyClass in above example). So you can reference to some state as &Me::x_StateFunctionName (all state implementing methods should be private as they shouldn't be used anywhere outside this state machine). Methods implementing states shouldn't take any arguments and should return next state for this machine to go to (for convenience there's typedef State to use as return type of methods). When state-implementing method returns some non-NULL pointer to next state machine will go to next state immediately. If state-implementing method returns NULL it means that state of the machine shouldn't change and the same state-implementing method should be called next time TaskServer calls ExecuteSlice() of this task. If you need to change machine's state but not execute it immediately or yield thread's time to other tasks waiting for execution you can use a sequence like this:
SetState(&Me::x_NextState); SetRunnable(); // use RunAfter() here if you need to execute later return NULL;
Initial state of the machine should be set using SetState() in your class constructor.
Virtual inheritance from CSrvTask is used to allow derived classes to combine several task types together (such as CSrvSocketTask, CSrvStatesTask etc.) and still have one implementation of CSrvTask.
Definition at line 282 of file srv_tasks.hpp.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4