ReactESP 3.2.0
Asynchronous programming for the ESP microcontrollers
Loading...
Searching...
No Matches
reactesp::EventLoop Class Reference

Asynchronous event loop supporting timed (repeating and non-repeating), interrupt and stream events. More...

#include <event_loop.h>

Public Member Functions

 EventLoop ()
 Construct a new EventLoop object.
 
 EventLoop (const EventLoop &)=delete
 
 EventLoop (EventLoop &&)=delete
 
int getTimedEventQueueSize ()
 
int getUntimedEventQueueSize ()
 
int getISREventQueueSize ()
 
int getEventQueueSize ()
 
uint64_t getTimedEventCount ()
 
uint64_t getUntimedEventCount ()
 
uint64_t getEventCount ()
 
uint64_t getTickCount ()
 
void tick ()
 
DelayEventonDelay (uint32_t delay, react_callback callback)
 Create a new DelayEvent.
 
DelayEventonDelayMicros (uint64_t delay, react_callback callback)
 Create a new DelayEvent.
 
RepeatEventonRepeat (uint32_t interval, react_callback callback)
 Create a new RepeatEvent.
 
RepeatEventonRepeatMicros (uint64_t interval, react_callback callback)
 Create a new RepeatEvent.
 
StreamEventonAvailable (Stream &stream, react_callback callback)
 Create a new StreamEvent.
 
ISREventonInterrupt (uint8_t pin_number, int mode, react_callback callback)
 Create a new ISREvent (interrupt event)
 
TickEventonTick (react_callback callback)
 Create a new TickEvent.
 
void remove (TimedEvent *event)
 
void remove (UntimedEvent *event)
 
void remove (ISREvent *event)
 
void remove (Event *event)
 Remove an event from the list of active events.
 

Protected Member Functions

void tickTimed ()
 
void tickUntimed ()
 

Protected Attributes

std::priority_queue< TimedEvent *, std::vector< TimedEvent * >, TriggerTimeComparetimed_queue
 
std::vector< UntimedEvent * > untimed_list
 
std::vector< ISREvent * > isr_event_list
 
SemaphoreHandle_t timed_queue_mutex_
 
SemaphoreHandle_t untimed_list_mutex_
 
SemaphoreHandle_t isr_event_list_mutex_
 
uint64_t timed_event_counter = 0
 
uint64_t untimed_event_counter = 0
 
uint64_t tick_counter = 0
 

Friends

class Event
 
class TimedEvent
 
class RepeatEvent
 
class UntimedEvent
 
class ISREvent
 

Detailed Description

Asynchronous event loop supporting timed (repeating and non-repeating), interrupt and stream events.

Definition at line 14 of file event_loop.h.

Constructor & Destructor Documentation

◆ EventLoop() [1/3]

reactesp::EventLoop::EventLoop ( )
inline

Construct a new EventLoop object.

Definition at line 25 of file event_loop.h.

◆ EventLoop() [2/3]

reactesp::EventLoop::EventLoop ( const EventLoop & )
delete

◆ EventLoop() [3/3]

reactesp::EventLoop::EventLoop ( EventLoop && )
delete

Member Function Documentation

◆ getEventCount()

uint64_t reactesp::EventLoop::getEventCount ( )
inline

Definition at line 52 of file event_loop.h.

Here is the call graph for this function:

◆ getEventQueueSize()

int reactesp::EventLoop::getEventQueueSize ( )
inline

Definition at line 45 of file event_loop.h.

Here is the call graph for this function:

◆ getISREventQueueSize()

int reactesp::EventLoop::getISREventQueueSize ( )
inline

Definition at line 44 of file event_loop.h.

Here is the caller graph for this function:

◆ getTickCount()

uint64_t reactesp::EventLoop::getTickCount ( )
inline

Definition at line 56 of file event_loop.h.

◆ getTimedEventCount()

uint64_t reactesp::EventLoop::getTimedEventCount ( )
inline

Definition at line 50 of file event_loop.h.

Here is the caller graph for this function:

◆ getTimedEventQueueSize()

int reactesp::EventLoop::getTimedEventQueueSize ( )
inline

Definition at line 42 of file event_loop.h.

Here is the caller graph for this function:

◆ getUntimedEventCount()

uint64_t reactesp::EventLoop::getUntimedEventCount ( )
inline

Definition at line 51 of file event_loop.h.

Here is the caller graph for this function:

◆ getUntimedEventQueueSize()

int reactesp::EventLoop::getUntimedEventQueueSize ( )
inline

Definition at line 43 of file event_loop.h.

Here is the caller graph for this function:

◆ onAvailable()

StreamEvent * reactesp::EventLoop::onAvailable ( Stream & stream,
react_callback callback )

Create a new StreamEvent.

Parameters
streamArduino Stream object to monitor
callbackCallback function
Returns
StreamEvent*

Definition at line 74 of file event_loop.cpp.

Here is the caller graph for this function:

◆ onDelay()

DelayEvent * reactesp::EventLoop::onDelay ( uint32_t delay,
react_callback callback )

Create a new DelayEvent.

Parameters
delayDelay, in milliseconds
callbackCallback function
Returns
DelayEvent*

Definition at line 49 of file event_loop.cpp.

Here is the caller graph for this function:

◆ onDelayMicros()

DelayEvent * reactesp::EventLoop::onDelayMicros ( uint64_t delay,
react_callback callback )

Create a new DelayEvent.

Parameters
delayDelay, in microseconds
callbackCallback function
Returns
DelayEvent*

Definition at line 55 of file event_loop.cpp.

◆ onInterrupt()

ISREvent * reactesp::EventLoop::onInterrupt ( uint8_t pin_number,
int mode,
react_callback callback )

Create a new ISREvent (interrupt event)

Parameters
pin_numberGPIO pin number
modeOne of CHANGE, RISING, FALLING
callbackInterrupt handler to call. This should be a very simple function, ideally setting a flag variable or incrementing a counter. The function should be defined with ICACHE_RAM_ATTR.
Returns
ISREvent*

Definition at line 80 of file event_loop.cpp.

Here is the caller graph for this function:

◆ onRepeat()

RepeatEvent * reactesp::EventLoop::onRepeat ( uint32_t interval,
react_callback callback )

Create a new RepeatEvent.

Parameters
delayInterval, in milliseconds
callbackCallback function
Returns
RepeatEvent*

Definition at line 61 of file event_loop.cpp.

Here is the caller graph for this function:

◆ onRepeatMicros()

RepeatEvent * reactesp::EventLoop::onRepeatMicros ( uint64_t interval,
react_callback callback )

Create a new RepeatEvent.

Parameters
delayInterval, in microseconds
callbackCallback function
Returns
RepeatEvent*

Definition at line 67 of file event_loop.cpp.

◆ onTick()

TickEvent * reactesp::EventLoop::onTick ( react_callback callback)

Create a new TickEvent.

Parameters
callbackCallback function to be called at every loop execution
Returns
TickEvent*

Definition at line 87 of file event_loop.cpp.

Here is the caller graph for this function:

◆ remove() [1/4]

void reactesp::EventLoop::remove ( Event * event)

Remove an event from the list of active events.

Parameters
eventEvent to remove

Definition at line 114 of file event_loop.cpp.

◆ remove() [2/4]

void reactesp::EventLoop::remove ( ISREvent * event)

Definition at line 104 of file event_loop.cpp.

◆ remove() [3/4]

void reactesp::EventLoop::remove ( TimedEvent * event)

Definition at line 93 of file event_loop.cpp.

◆ remove() [4/4]

void reactesp::EventLoop::remove ( UntimedEvent * event)

Definition at line 95 of file event_loop.cpp.

◆ tick()

void reactesp::EventLoop::tick ( )

Definition at line 43 of file event_loop.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tickTimed()

void reactesp::EventLoop::tickTimed ( )
protected

Definition at line 7 of file event_loop.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tickUntimed()

void reactesp::EventLoop::tickUntimed ( )
protected

Definition at line 34 of file event_loop.cpp.

Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ Event

friend class Event
friend

Definition at line 15 of file event_loop.h.

◆ ISREvent

friend class ISREvent
friend

Definition at line 19 of file event_loop.h.

◆ RepeatEvent

friend class RepeatEvent
friend

Definition at line 17 of file event_loop.h.

◆ TimedEvent

friend class TimedEvent
friend

Definition at line 16 of file event_loop.h.

◆ UntimedEvent

friend class UntimedEvent
friend

Definition at line 18 of file event_loop.h.

Member Data Documentation

◆ isr_event_list

std::vector<ISREvent*> reactesp::EventLoop::isr_event_list
protected

Definition at line 142 of file event_loop.h.

◆ isr_event_list_mutex_

SemaphoreHandle_t reactesp::EventLoop::isr_event_list_mutex_
protected

Definition at line 147 of file event_loop.h.

◆ tick_counter

uint64_t reactesp::EventLoop::tick_counter = 0
protected

Definition at line 151 of file event_loop.h.

◆ timed_event_counter

uint64_t reactesp::EventLoop::timed_event_counter = 0
protected

Definition at line 149 of file event_loop.h.

◆ timed_queue

std::priority_queue<TimedEvent*, std::vector<TimedEvent*>, TriggerTimeCompare> reactesp::EventLoop::timed_queue
protected

Definition at line 135 of file event_loop.h.

◆ timed_queue_mutex_

SemaphoreHandle_t reactesp::EventLoop::timed_queue_mutex_
protected

Definition at line 145 of file event_loop.h.

◆ untimed_event_counter

uint64_t reactesp::EventLoop::untimed_event_counter = 0
protected

Definition at line 150 of file event_loop.h.

◆ untimed_list

std::vector<UntimedEvent*> reactesp::EventLoop::untimed_list
protected

Definition at line 139 of file event_loop.h.

◆ untimed_list_mutex_

SemaphoreHandle_t reactesp::EventLoop::untimed_list_mutex_
protected

Definition at line 146 of file event_loop.h.


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