|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Base class for event loops. More...
Classes | |
| class | listener_handle |
| Handle to a registered event listener. More... | |
| struct | task_config |
| Configuration for a dedicated event dispatch task. More... | |
| class | unique_listener_handle |
| RAII handle for event listener registration. More... | |
Public Member Functions | |
| event_loop (task_config task, size_t queue_size=32) | |
| Creates an event loop with a dedicated dispatch task. | |
| template<typename IdEnum , typename DataType > | |
| listener_handle | listener_add (event< IdEnum, DataType > event, event_handler< DataType > callback) |
| Registers a type-safe listener for a specific event. | |
| template<typename IdEnum > | |
| listener_handle | listener_add (event_base< IdEnum > base, opaque_event_handler< std::type_identity_t< IdEnum > > callback) |
| Registers a listener for any event from a base. | |
| template<typename IdEnum , typename DataType > | |
| result< listener_handle > | try_listener_add (event< IdEnum, DataType > event, event_handler< DataType > callback) |
| Registers a type-safe listener for a specific event. | |
| template<typename IdEnum > | |
| result< listener_handle > | try_listener_add (event_base< IdEnum > base, opaque_event_handler< std::type_identity_t< IdEnum > > callback) |
| Registers a listener for any event from a base. | |
| void | listener_remove (listener_handle handle) |
| Removes a listener by handle. | |
| result< void > | try_listener_remove (listener_handle handle) |
| Removes a listener by handle. | |
| template<typename IdEnum > | |
| void | post (event< IdEnum > evt) |
| Posts an event without data, waiting indefinitely. | |
| template<typename IdEnum , typename Rep , typename Period > | |
| void | post (event< IdEnum > evt, const std::chrono::duration< Rep, Period > &timeout) |
| Posts an event without data, with a timeout. | |
| template<typename IdEnum , typename DataType > requires event_data<DataType> | |
| void | post (event< IdEnum, DataType > evt, const DataType &data) |
| Posts an event with data, waiting indefinitely. | |
| template<typename IdEnum , typename DataType , typename Rep , typename Period > requires event_data<DataType> | |
| void | post (event< IdEnum, DataType > evt, const DataType &data, const std::chrono::duration< Rep, Period > &timeout) |
| Posts an event with data, with a timeout. | |
| template<typename IdEnum > | |
| result< void > | try_post (event< IdEnum > evt) |
| Posts an event without data, waiting indefinitely. | |
| template<typename IdEnum , typename Rep , typename Period > | |
| result< void > | try_post (event< IdEnum > evt, const std::chrono::duration< Rep, Period > &timeout) |
| Posts an event without data, with a timeout. | |
| template<typename IdEnum , typename DataType > requires event_data<DataType> | |
| result< void > | try_post (event< IdEnum, DataType > evt, const DataType &data) |
| Posts an event with data, waiting indefinitely. | |
| template<typename IdEnum , typename DataType , typename Rep , typename Period > requires event_data<DataType> | |
| result< void > | try_post (event< IdEnum, DataType > evt, const DataType &data, const std::chrono::duration< Rep, Period > &timeout) |
| Posts an event with data, with a timeout. | |
| esp_event_loop_handle_t | idf_handle () const |
| Returns the underlying ESP-IDF event loop handle. | |
| ~event_loop () | |
| event_loop (const event_loop &)=delete | |
| event_loop & | operator= (const event_loop &)=delete |
| event_loop (event_loop &&other) noexcept | |
| Move constructor. | |
| event_loop & | operator= (event_loop &&other) noexcept |
| Move assignment. | |
Static Public Member Functions | |
| static void | create_system () |
| Creates the system (default) event loop. | |
| static void | destroy_system () |
| Destroys the system (default) event loop. | |
| static result< void > | try_create_system () |
| Creates the system (default) event loop. | |
| static result< void > | try_destroy_system () |
| Destroys the system (default) event loop. | |
| static event_loop & | system () |
| Returns a reference to the system (default) event loop. | |
| static result< event_loop > | make (task_config task, size_t queue_size=32) |
| Creates an event loop with a dedicated dispatch task. | |
Protected Member Functions | |
| event_loop ()=default | |
| event_loop (esp_event_loop_handle_t handle, bool system=false) | |
| Constructs an event_loop with the given handle. | |
Base class for event loops.
Provides listener registration and event posting operations. This type is non-copyable and move-only. Result-returning methods on a moved-from object return errc::invalid_state. Simple accessors return default/null values.
|
explicit |
Creates an event loop with a dedicated dispatch task.
The task automatically dispatches events from the queue.
| task | Configuration for the dedicated dispatch task. |
| queue_size | Maximum number of events in the queue. |
| std::system_error | on failure. |
| idfxx::event_loop::~event_loop | ( | ) |
|
delete |
|
noexcept |
Move constructor.
Transfers ownership of the event loop.
|
protecteddefault |
|
inlineexplicitprotected |
Constructs an event_loop with the given handle.
| handle | The ESP-IDF event loop handle, or nullptr for the system loop. |
| system | If true, this is the system event loop singleton. |
Creates the system (default) event loop.
| std::system_error | on failure. |
Definition at line 316 of file event.hpp.
References idfxx::unwrap().
Destroys the system (default) event loop.
| std::system_error | on failure. |
Definition at line 324 of file event.hpp.
References idfxx::unwrap().
|
inline |
|
static |
Creates an event loop with a dedicated dispatch task.
The task automatically dispatches events from the queue.
| task | Configuration for the dedicated dispatch task. |
| queue_size | Maximum number of events in the queue. |
|
delete |
|
noexcept |
Move assignment.
Transfers ownership of the event loop.
Posts an event without data, waiting indefinitely.
| IdEnum | The event ID enum type. |
| evt | The event to post. |
| std::system_error | on failure. |
Definition at line 522 of file event.hpp.
References idfxx::unwrap().
|
inline |
Posts an event without data, with a timeout.
| IdEnum | The event ID enum type. |
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| evt | The event to post. |
| timeout | Maximum time to wait for space in the event queue. |
| std::system_error | on failure or timeout. |
Definition at line 539 of file event.hpp.
References idfxx::timeout, and idfxx::unwrap().
Posts an event with data, waiting indefinitely.
| IdEnum | The event ID enum type. |
| DataType | The event data type. |
| evt | The event to post. |
| data | The event data. |
| std::system_error | on failure. |
Definition at line 560 of file event.hpp.
References idfxx::unwrap().
|
inline |
Posts an event with data, with a timeout.
| IdEnum | The event ID enum type. |
| DataType | The event data type (must satisfy event_data). |
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| evt | The event to post. |
| data | The event data. |
| timeout | Maximum time to wait for space in the event queue. |
| std::system_error | on failure or timeout. |
Definition at line 580 of file event.hpp.
References idfxx::timeout, and idfxx::unwrap().
|
static |
Returns a reference to the system (default) event loop.
Creates the system (default) event loop.
Destroys the system (default) event loop.
| result< void > idfxx::event_loop::try_listener_remove | ( | listener_handle | handle | ) |
Removes a listener by handle.
| handle | The listener handle to remove. |
|
inline |
Posts an event without data, with a timeout.
| IdEnum | The event ID enum type. |
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| evt | The event to post. |
| timeout | Maximum time to wait for space in the event queue. |
Definition at line 608 of file event.hpp.
References idfxx::chrono::ticks(), and idfxx::timeout.
|
inline |
Posts an event with data, waiting indefinitely.
The data type must satisfy event_data (receivable and trivially copyable).
| IdEnum | The event ID enum type. |
| DataType | The event data type (must satisfy event_data). |
| evt | The event to post. |
| data | The event data. |
|
inline |
Posts an event with data, with a timeout.
The data type must satisfy event_data (receivable and trivially copyable).
| IdEnum | The event ID enum type. |
| DataType | The event data type (must satisfy event_data). |
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| evt | The event to post. |
| data | The event data. |
| timeout | Maximum time to wait for space in the event queue. |
Definition at line 650 of file event.hpp.
References idfxx::chrono::ticks(), and idfxx::timeout.