Parking Garage Control System
ESP32 Parking Garage – ESP-IDF/FreeRTOS
Loading...
Searching...
No Matches
FreeRtosEventBus Class Reference

FreeRTOS implementation of event bus. More...

#include <FreeRtosEventBus.h>

Inheritance diagram for FreeRtosEventBus:
Collaboration diagram for FreeRtosEventBus:

Public Member Functions

 FreeRtosEventBus (size_t queueSize=32)
 Construct event bus.
 
 ~FreeRtosEventBus () override
 
 FreeRtosEventBus (const FreeRtosEventBus &)=delete
 
FreeRtosEventBus & operator= (const FreeRtosEventBus &)=delete
 
void subscribe (EventType type, std::function< void(const Event &)> handler) override
 Subscribe to specific event type.
 
void publish (const Event &event) override
 Publish event to all subscribers.
 
void processAllPending () override
 Process all pending events (for synchronous testing)
 
bool waitForEvent (Event &outEvent, uint32_t timeoutMs) override
 Wait for next event (blocking, for FreeRTOS tasks)
 
bool publishFromISR (const Event &event)
 Publish event from ISR context.
 
void startEventLoop (uint32_t stackSize=4096, UBaseType_t priority=5, const char *taskName="event_loop")
 Start the internal event loop task.
 
void stopEventLoop ()
 Stop the internal event loop task.
 
bool isEventLoopRunning () const
 Check if event loop is running.
 
- Public Member Functions inherited from IEventBus
virtual ~IEventBus ()=default
 

Detailed Description

FreeRTOS implementation of event bus.

Thread-safe event bus using FreeRTOS queue and mutex. Supports both asynchronous event publishing and synchronous event processing. Can run its own event loop task for automatic event dispatching.

Constructor & Destructor Documentation

◆ FreeRtosEventBus() [1/2]

FreeRtosEventBus::FreeRtosEventBus ( size_t  queueSize = 32)
explicit

Construct event bus.

Parameters
queueSizeMaximum number of queued events

◆ ~FreeRtosEventBus()

FreeRtosEventBus::~FreeRtosEventBus ( )
override

◆ FreeRtosEventBus() [2/2]

FreeRtosEventBus::FreeRtosEventBus ( const FreeRtosEventBus &  )
delete

Member Function Documentation

◆ isEventLoopRunning()

bool FreeRtosEventBus::isEventLoopRunning ( ) const

Check if event loop is running.

Returns
true if event loop task is active

◆ operator=()

FreeRtosEventBus & FreeRtosEventBus::operator= ( const FreeRtosEventBus &  )
delete

◆ processAllPending()

void FreeRtosEventBus::processAllPending ( )
overridevirtual

Process all pending events (for synchronous testing)

Implements IEventBus.

◆ publish()

void FreeRtosEventBus::publish ( const Event &  event)
overridevirtual

Publish event to all subscribers.

Parameters
eventEvent to publish

Implements IEventBus.

◆ publishFromISR()

bool FreeRtosEventBus::publishFromISR ( const Event &  event)

Publish event from ISR context.

Parameters
eventEvent to publish
Returns
true if event was queued successfully

◆ startEventLoop()

void FreeRtosEventBus::startEventLoop ( uint32_t  stackSize = 4096,
UBaseType_t  priority = 5,
const char *  taskName = "event_loop" 
)

Start the internal event loop task.

Creates a FreeRTOS task that continuously processes events from the queue. This is the recommended way to run the event bus in production.

Parameters
stackSizeTask stack size in bytes (default: 4096)
priorityTask priority (default: 5)
taskNameName for the task (default: "event_loop")

◆ stopEventLoop()

void FreeRtosEventBus::stopEventLoop ( )

Stop the internal event loop task.

Stops and deletes the event loop task if running.

◆ subscribe()

void FreeRtosEventBus::subscribe ( EventType  type,
std::function< void(const Event &)>  handler 
)
overridevirtual

Subscribe to specific event type.

Parameters
typeEvent type to subscribe to
handlerCallback function called when event occurs

Implements IEventBus.

◆ waitForEvent()

bool FreeRtosEventBus::waitForEvent ( Event &  outEvent,
uint32_t  timeoutMs 
)
overridevirtual

Wait for next event (blocking, for FreeRTOS tasks)

Parameters
outEventOutput event structure
timeoutMsTimeout in milliseconds (portMAX_DELAY for infinite)
Returns
true if event received, false on timeout

Implements IEventBus.


The documentation for this class was generated from the following files:
Coverage