avr-classes
Public Member Functions | List of all members
QueuedEventDispatcher< SUBSCRIBERCOUNT, QUEUESIZE > Class Template Reference

#include <queuedeventdispatcher.h>

Inheritance diagram for QueuedEventDispatcher< SUBSCRIBERCOUNT, QUEUESIZE >:
EventDispatcher< SUBSCRIBERCOUNT > EventReceiver

Public Member Functions

virtual void onEvent (const Event &event) override
 
void dispatch (void)
 
bool isIdle (void)
 
- Public Member Functions inherited from EventDispatcher< SUBSCRIBERCOUNT >
bool subscribe (EventReceiver *subscriber)
 
void unsubscribe (EventReceiver *subscriber)
 

Detailed Description

template<uint8_t SUBSCRIBERCOUNT, uint8_t QUEUESIZE>
class QueuedEventDispatcher< SUBSCRIBERCOUNT, QUEUESIZE >

This component is able to receive events and puts them into a queue. When calling the dispatch() method, the events are sent to all subscribers. Since queuing and dispatching can happen from different contexts, the QueuedEventDispatcher can be used to decouple ISR context and main context.

Parameters
SUBSCRIBERCOUNTMaximum number of subscribers.
QUEUESIZEMaximum number of events that can be queued.

Member Function Documentation

◆ dispatch()

template<uint8_t SUBSCRIBERCOUNT, uint8_t QUEUESIZE>
void QueuedEventDispatcher< SUBSCRIBERCOUNT, QUEUESIZE >::dispatch ( void  )
inline

Dispatches the events from the queue by sending each one to all subscribers.

◆ isIdle()

template<uint8_t SUBSCRIBERCOUNT, uint8_t QUEUESIZE>
bool QueuedEventDispatcher< SUBSCRIBERCOUNT, QUEUESIZE >::isIdle ( void  )
inline

Indicates if event queue is empty or requires dispatching.

Returns
True if event queue is empty, false otherwise.

◆ onEvent()

template<uint8_t SUBSCRIBERCOUNT, uint8_t QUEUESIZE>
virtual void QueuedEventDispatcher< SUBSCRIBERCOUNT, QUEUESIZE >::onEvent ( const Event event)
inlineoverridevirtual

Handler for incoming events. The passed event is put into the event queue. If the queue is full, the event is silently discarded.

Parameters
eventEvent to handle.

Reimplemented from EventDispatcher< SUBSCRIBERCOUNT >.