Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::EventHandler Class Referenceabstract

#include <EventHandler.h>

Inheritance diagram for Boardcore::EventHandler:
Collaboration diagram for Boardcore::EventHandler:

Public Member Functions

 EventHandler (unsigned int stacksize=miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority=miosix::MAIN_PRIORITY)
 
virtual ~EventHandler ()
 
void postEvent (const Event &ev) override
 
void stop () override
 Signals the runner thread to terminate and joins the thread.
 
- Public Member Functions inherited from Boardcore::EventHandlerBase
 EventHandlerBase ()
 
virtual ~EventHandlerBase ()
 
- Public Member Functions inherited from Boardcore::ActiveObject
 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.
 
bool isRunning ()
 

Protected Member Functions

virtual void handleEvent (const Event &ev)=0
 
void run () override
 
- Protected Member Functions inherited from Boardcore::ActiveObject
bool shouldStop ()
 Tells whether or not the ActiveObject should stop its execution.
 

Protected Attributes

SynchronizedQueue< EventeventList
 
- Protected Attributes inherited from Boardcore::ActiveObject
miosix::Thread * thread = nullptr
 Gives access to the thread object.
 
std::atomic< bool > stopFlag {false}
 
std::atomic< bool > running {false}
 

Detailed Description

Definition at line 44 of file EventHandler.h.

Constructor & Destructor Documentation

◆ EventHandler()

Boardcore::EventHandler::EventHandler ( unsigned int stacksize = miosix::STACK_DEFAULT_FOR_PTHREAD,
miosix::Priority priority = miosix::MAIN_PRIORITY )
inline

Definition at line 64 of file EventHandler.h.

◆ ~EventHandler()

Boardcore::EventHandler::~EventHandler ( )
inlinevirtual

Definition at line 70 of file EventHandler.h.

Member Function Documentation

◆ handleEvent()

virtual void Boardcore::EventHandler::handleEvent ( const Event & ev)
protectedpure virtual

◆ postEvent()

void Boardcore::EventHandler::postEvent ( const Event & ev)
inlineoverridevirtual

Implements Boardcore::EventHandlerBase.

Definition at line 72 of file EventHandler.h.

◆ run()

void Boardcore::EventHandler::run ( )
inlineoverrideprotectedvirtual

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.

Implements Boardcore::ActiveObject.

Definition at line 87 of file EventHandler.h.

◆ stop()

void Boardcore::EventHandler::stop ( )
inlineoverridevirtual

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 from Boardcore::ActiveObject.

Definition at line 74 of file EventHandler.h.

Member Data Documentation

◆ eventList

SynchronizedQueue<Event> Boardcore::EventHandler::eventList
protected

Definition at line 61 of file EventHandler.h.


The documentation for this class was generated from the following file: