ReactESP 3.3.1
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 Types

using TimedEventSet = std::set<TimedEvent*, TriggerTimeCompare>

Protected Member Functions

void tickTimed ()
void tickUntimed ()

Protected Attributes

TimedEventSet timed_events_
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 15 of file event_loop.h.

Member Typedef Documentation

◆ TimedEventSet

Definition at line 139 of file event_loop.h.

Constructor & Destructor Documentation

◆ EventLoop() [1/3]

reactesp::EventLoop::EventLoop ( )
inline

Construct a new EventLoop object.

Definition at line 26 of file event_loop.h.

Here is the caller graph for this function:

◆ EventLoop() [2/3]

reactesp::EventLoop::EventLoop ( const EventLoop & )
delete
Here is the call graph for this function:

◆ EventLoop() [3/3]

reactesp::EventLoop::EventLoop ( EventLoop && )
delete
Here is the call graph for this function:

Member Function Documentation

◆ getEventCount()

uint64_t reactesp::EventLoop::getEventCount ( )
inline

Definition at line 53 of file event_loop.h.

Here is the call graph for this function:

◆ getEventQueueSize()

int reactesp::EventLoop::getEventQueueSize ( )
inline

Definition at line 46 of file event_loop.h.

Here is the call graph for this function:

◆ getISREventQueueSize()

int reactesp::EventLoop::getISREventQueueSize ( )
inline

Definition at line 45 of file event_loop.h.

Here is the caller graph for this function:

◆ getTickCount()

uint64_t reactesp::EventLoop::getTickCount ( )
inline

Definition at line 57 of file event_loop.h.

◆ getTimedEventCount()

uint64_t reactesp::EventLoop::getTimedEventCount ( )
inline

Definition at line 51 of file event_loop.h.

Here is the caller graph for this function:

◆ getTimedEventQueueSize()

int reactesp::EventLoop::getTimedEventQueueSize ( )
inline

Definition at line 43 of file event_loop.h.

Here is the caller graph for this function:

◆ getUntimedEventCount()

uint64_t reactesp::EventLoop::getUntimedEventCount ( )
inline

Definition at line 52 of file event_loop.h.

Here is the caller graph for this function:

◆ getUntimedEventQueueSize()

int reactesp::EventLoop::getUntimedEventQueueSize ( )
inline

Definition at line 44 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 94 of file event_loop.cpp.

◆ 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 69 of file event_loop.cpp.

◆ 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 75 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 100 of file event_loop.cpp.

Here is the call 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 81 of file event_loop.cpp.

Here is the call 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 87 of file event_loop.cpp.

Here is the call graph for this function:

◆ 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 107 of file event_loop.cpp.

◆ 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 134 of file event_loop.cpp.

Here is the call graph for this function:

◆ remove() [2/4]

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

Definition at line 124 of file event_loop.cpp.

Here is the call graph for this function:

◆ remove() [3/4]

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

Definition at line 113 of file event_loop.cpp.

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

◆ remove() [4/4]

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

Definition at line 115 of file event_loop.cpp.

Here is the call graph for this function:

◆ tick()

void reactesp::EventLoop::tick ( )

Definition at line 63 of file event_loop.cpp.

Here is the call 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 54 of file event_loop.cpp.

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

◆ Event

friend class Event
friend

Definition at line 16 of file event_loop.h.

◆ ISREvent

friend class ISREvent
friend

Definition at line 20 of file event_loop.h.

◆ RepeatEvent

friend class RepeatEvent
friend

Definition at line 18 of file event_loop.h.

◆ TimedEvent

friend class TimedEvent
friend

Definition at line 17 of file event_loop.h.

◆ UntimedEvent

friend class UntimedEvent
friend

Definition at line 19 of file event_loop.h.

Member Data Documentation

◆ isr_event_list

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

Definition at line 147 of file event_loop.h.

◆ isr_event_list_mutex_

SemaphoreHandle_t reactesp::EventLoop::isr_event_list_mutex_
protected

Definition at line 152 of file event_loop.h.

◆ tick_counter

uint64_t reactesp::EventLoop::tick_counter = 0
protected

Definition at line 156 of file event_loop.h.

◆ timed_event_counter

uint64_t reactesp::EventLoop::timed_event_counter = 0
protected

Definition at line 154 of file event_loop.h.

◆ timed_events_

TimedEventSet reactesp::EventLoop::timed_events_
protected

Definition at line 140 of file event_loop.h.

◆ timed_queue_mutex_

SemaphoreHandle_t reactesp::EventLoop::timed_queue_mutex_
protected

Definition at line 150 of file event_loop.h.

◆ untimed_event_counter

uint64_t reactesp::EventLoop::untimed_event_counter = 0
protected

Definition at line 155 of file event_loop.h.

◆ untimed_list

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

Definition at line 144 of file event_loop.h.

◆ untimed_list_mutex_

SemaphoreHandle_t reactesp::EventLoop::untimed_list_mutex_
protected

Definition at line 151 of file event_loop.h.


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