Skyward boardcore
|
#include <ActiveObject.h>
Public Member Functions | |
ActiveObject (unsigned int stacksize=miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority=miosix::MAIN_PRIORITY) | |
virtual | ~ActiveObject () |
virtual bool | start () |
Start the thread associated with this active object. | |
virtual void | stop () |
Signals the runner thread to terminate and joins the thread. | |
bool | isRunning () |
Protected Member Functions | |
virtual void | run ()=0 |
bool | shouldStop () |
Tells whether or not the ActiveObject should stop its execution. | |
Protected Attributes | |
miosix::Thread * | thread = nullptr |
Gives access to the thread object. | |
std::atomic< bool > | stopFlag {false} |
std::atomic< bool > | running {false} |
Utility class implementing the Active Object pattern Deriving from this class causes a thread to be spawned for each instance. This thread will call the run() function.
Definition at line 38 of file ActiveObject.h.
|
inline |
Constructor. This will create the AO, but will NOT start the thread associated with it. call start() in order to start the thread.
stacksize | the stack of the thread that will be spawned |
priority | priority of the thread that will be spawned |
Definition at line 109 of file ActiveObject.h.
|
inlinevirtual |
Definition at line 50 of file ActiveObject.h.
|
inline |
Definition at line 144 of file ActiveObject.h.
|
protectedpure virtual |
The thread that will be spawned just calls this function. Override it to implement your logic. Remember to frequently check for shouldStop() to see if you should terminate the execution of the thread.
Implemented in Boardcore::EventHandler, Boardcore::EventInjector, Boardcore::SignaledDeadlineTask, and Boardcore::ScreenManager.
|
inlineprotected |
Tells whether or not the ActiveObject should stop its execution.
Your implementation of the run() method should periodically check this function and should terminate as soon as possible if required to.
Definition at line 146 of file ActiveObject.h.
|
inlinevirtual |
Start the thread associated with this active object.
Call stop() to terminate execution of the thread.
Reimplemented in Boardcore::HSM< T >, Boardcore::HIL< FlightPhases, SimulatorData, ActuatorData >, and Boardcore::TaskScheduler.
Definition at line 115 of file ActiveObject.h.
|
inlinevirtual |
Signals the runner thread to terminate and joins the thread.
This is a blocking call that will not return until the thread terminates! Your run() implementation must check shouldStop() and terminate ASAP if it returns true.
Reimplemented in Boardcore::HIL< FlightPhases, SimulatorData, ActuatorData >, Boardcore::EventHandler, and Boardcore::TaskScheduler.
Definition at line 135 of file ActiveObject.h.
|
protected |
Definition at line 95 of file ActiveObject.h.
|
protected |
Definition at line 94 of file ActiveObject.h.
|
protected |
Gives access to the thread object.
Definition at line 92 of file ActiveObject.h.