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

TimedEvents are called based on elapsing of time. More...

#include <events.h>

Inheritance diagram for reactesp::TimedEvent:
[legend]
Collaboration diagram for reactesp::TimedEvent:
[legend]

Public Member Functions

 TimedEvent (uint32_t interval, react_callback callback)
 Construct a new Timed Event object.
 TimedEvent (uint64_t interval, react_callback callback)
 Construct a new Timed Event object.
bool operator< (const TimedEvent &other) const
virtual void add (EventLoop *event_loop) override
virtual void remove (EventLoop *event_loop) override
uint32_t getTriggerTime () const
uint64_t getTriggerTimeMicros () const
bool isEnabled () const
 Check if the event is still active.
virtual void add (std::shared_ptr< EventLoop > event_loop)
virtual void remove (std::shared_ptr< EventLoop > event_loop)
virtual void tick (EventLoop *event_loop)=0
virtual void tick (std::shared_ptr< EventLoop > event_loop)
Public Member Functions inherited from reactesp::Event
 Event (react_callback callback)
 Construct a new Event object.
 Event (const Event &)=delete
 Event (Event &&)=delete
Eventoperator= (const Event &)=delete
Eventoperator= (Event &&)=delete
Public Member Functions inherited from reactesp::EventInterface
virtual ~EventInterface ()=default
 Default virtual destructor.

Protected Attributes

const uint64_t interval
uint64_t last_trigger_time
bool enabled
Protected Attributes inherited from reactesp::Event
const react_callback callback

Detailed Description

TimedEvents are called based on elapsing of time.

Definition at line 77 of file events.h.

Constructor & Destructor Documentation

◆ TimedEvent() [1/2]

reactesp::TimedEvent::TimedEvent ( uint32_t interval,
react_callback callback )
inline

Construct a new Timed Event object.

Parameters
intervalInterval or delay for the event, in milliseconds
callbackFunction to be called when the event is triggered

Definition at line 90 of file events.h.

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

◆ TimedEvent() [2/2]

reactesp::TimedEvent::TimedEvent ( uint64_t interval,
react_callback callback )
inline

Construct a new Timed Event object.

Parameters
intervalInterval, in microseconds
callbackFunction to be called when the event is triggered

Definition at line 101 of file events.h.

Here is the call graph for this function:

Member Function Documentation

◆ add() [1/2]

void reactesp::TimedEvent::add ( EventLoop * event_loop)
overridevirtual

Implements reactesp::EventInterface.

Definition at line 17 of file events.cpp.

◆ add() [2/2]

virtual void reactesp::EventInterface::add ( std::shared_ptr< EventLoop > event_loop)
inlinevirtual

Reimplemented from reactesp::EventInterface.

Definition at line 41 of file events.h.

◆ getTriggerTime()

uint32_t reactesp::TimedEvent::getTriggerTime ( ) const
inline

Definition at line 115 of file events.h.

◆ getTriggerTimeMicros()

uint64_t reactesp::TimedEvent::getTriggerTimeMicros ( ) const
inline

Definition at line 118 of file events.h.

Here is the caller graph for this function:

◆ isEnabled()

bool reactesp::TimedEvent::isEnabled ( ) const
inline

Check if the event is still active.

An event is active unless it was removed while being ticked (i.e., from within its own callback). In that case, tick() will delete the event instead of reinserting it.

Definition at line 129 of file events.h.

◆ operator<()

bool reactesp::TimedEvent::operator< ( const TimedEvent & other) const

Definition at line 12 of file events.cpp.

Here is the call graph for this function:

◆ remove() [1/2]

void reactesp::TimedEvent::remove ( EventLoop * event_loop)
overridevirtual

Implements reactesp::EventInterface.

Definition at line 23 of file events.cpp.

◆ remove() [2/2]

virtual void reactesp::EventInterface::remove ( std::shared_ptr< EventLoop > event_loop)
inlinevirtual

Reimplemented from reactesp::EventInterface.

Definition at line 44 of file events.h.

◆ tick() [1/2]

virtual void reactesp::EventInterface::tick ( EventLoop * event_loop)
virtual

◆ tick() [2/2]

virtual void reactesp::EventInterface::tick ( std::shared_ptr< EventLoop > event_loop)
inlinevirtual

Reimplemented from reactesp::EventInterface.

Definition at line 47 of file events.h.

Member Data Documentation

◆ enabled

bool reactesp::TimedEvent::enabled
protected

Definition at line 81 of file events.h.

◆ interval

const uint64_t reactesp::TimedEvent::interval
protected

Definition at line 79 of file events.h.

◆ last_trigger_time

uint64_t reactesp::TimedEvent::last_trigger_time
protected

Definition at line 80 of file events.h.


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