|
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 | |
| template<typename IdEnum > | |
| listener_handle | listener_add (event_base< IdEnum > base, IdEnum id, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for a specific event. | |
| template<typename IdEnum > | |
| listener_handle | listener_add (event_type< IdEnum > event, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for a specific event. | |
| template<typename IdEnum > | |
| listener_handle | listener_add (event_base< IdEnum > base, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for any event from a base. | |
| template<typename IdEnum > | |
| result< listener_handle > | try_listener_add (event_base< IdEnum > base, IdEnum id, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for a specific event. | |
| template<typename IdEnum > | |
| result< listener_handle > | try_listener_add (event_type< IdEnum > event, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for a specific event. | |
| template<typename IdEnum > | |
| result< listener_handle > | try_listener_add (event_base< IdEnum > base, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed 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_base< IdEnum > base, IdEnum id, const void *data=nullptr, size_t size=0) |
| Posts a typed event, waiting indefinitely. | |
| template<typename IdEnum , typename Rep , typename Period > | |
| void | post (event_base< IdEnum > base, IdEnum id, const void *data, size_t size, const std::chrono::duration< Rep, Period > &timeout) |
| Posts a typed event with a timeout. | |
| template<typename IdEnum > | |
| void | post (event_type< IdEnum > event, const void *data=nullptr, size_t size=0) |
| Posts a typed event via event_type, waiting indefinitely. | |
| template<typename IdEnum , typename Rep , typename Period > | |
| void | post (event_type< IdEnum > event, const void *data, size_t size, const std::chrono::duration< Rep, Period > &timeout) |
| Posts a typed event via event_type with a timeout. | |
| template<typename IdEnum > | |
| result< void > | try_post (event_base< IdEnum > base, IdEnum id, const void *data=nullptr, size_t size=0) |
| Posts a typed event, waiting indefinitely. | |
| template<typename IdEnum , typename Rep , typename Period > | |
| result< void > | try_post (event_base< IdEnum > base, IdEnum id, const void *data, size_t size, const std::chrono::duration< Rep, Period > &timeout) |
| Posts a typed event with a timeout. | |
| template<typename IdEnum > | |
| result< void > | try_post (event_type< IdEnum > event, const void *data=nullptr, size_t size=0) |
| Posts a typed event via event_type, waiting indefinitely. | |
| template<typename IdEnum , typename Rep , typename Period > | |
| result< void > | try_post (event_type< IdEnum > event, const void *data, size_t size, const std::chrono::duration< Rep, Period > &timeout) |
| Posts a typed event via event_type with a timeout. | |
| esp_event_loop_handle_t | idf_handle () const |
| Returns the underlying ESP-IDF event loop handle. | |
| virtual | ~event_loop () |
| Virtual destructor. | |
| event_loop (const event_loop &)=delete | |
| event_loop & | operator= (const event_loop &)=delete |
| event_loop (event_loop &&)=delete | |
| event_loop & | operator= (event_loop &&)=delete |
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 std::unique_ptr< user_event_loop > | make_user (size_t queue_size=32) |
| Creates a user event loop without a dedicated task. | |
| static std::unique_ptr< event_loop > | make_user (task_config task, size_t queue_size=32) |
| Creates a user event loop with a dedicated dispatch task. | |
| static result< std::unique_ptr< user_event_loop > > | try_make_user (size_t queue_size=32) |
| Creates a user event loop without a dedicated task. | |
| static result< std::unique_ptr< event_loop > > | try_make_user (task_config task, size_t queue_size=32) |
| Creates a user event loop with a dedicated dispatch task. | |
Protected Member Functions | |
| event_loop (esp_event_loop_handle_t handle) | |
| Constructs an event_loop with the given handle. | |
Base class for event loops.
Provides listener registration and event posting operations.
|
virtual |
Virtual destructor.
Deletes the owned event loop handle if non-null.
|
delete |
|
delete |
|
inlineexplicitprotected |
Constructs an event_loop with the given handle.
| handle | The ESP-IDF event loop handle, or nullptr for the system loop. |
|
inlinestatic |
Creates the system (default) event loop.
| std::system_error | on failure. |
Definition at line 227 of file event.hpp.
References try_create_system(), and idfxx::unwrap().
|
inlinestatic |
Destroys the system (default) event loop.
| std::system_error | on failure. |
Definition at line 235 of file event.hpp.
References try_destroy_system(), and idfxx::unwrap().
|
inline |
Returns the underlying ESP-IDF event loop handle.
Definition at line 604 of file event.hpp.
Referenced by idfxx::user_event_loop::try_run().
|
delete |
|
delete |
|
inline |
Posts a typed event with a timeout.
| IdEnum | The event ID enum type. |
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| base | The event base. |
| id | The event ID. |
| data | Event data. |
| size | Size of the event data. |
| timeout | Maximum time to wait for space in the event queue. |
| std::system_error | on failure or timeout. |
Definition at line 472 of file event.hpp.
References idfxx::timeout, try_post(), and idfxx::unwrap().
|
inline |
Posts a typed event, waiting indefinitely.
| IdEnum | The event ID enum type. |
| base | The event base. |
| id | The event ID. |
| data | Optional event data. |
| size | Size of the event data. |
| std::system_error | on failure. |
Definition at line 453 of file event.hpp.
References try_post(), and idfxx::unwrap().
|
inline |
Posts a typed event via event_type with a timeout.
| IdEnum | The event ID enum type. |
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| event | The event type (base + id). |
| data | Event data. |
| size | Size of the event data. |
| timeout | Maximum time to wait for space in the event queue. |
| std::system_error | on failure or timeout. |
Definition at line 512 of file event.hpp.
References idfxx::timeout, try_post(), and idfxx::unwrap().
|
inline |
Posts a typed event via event_type, waiting indefinitely.
| IdEnum | The event ID enum type. |
| event | The event type (base + id). |
| data | Optional event data. |
| size | Size of the event data. |
| std::system_error | on failure. |
Definition at line 493 of file event.hpp.
References try_post(), and idfxx::unwrap().
|
static |
Returns a reference to the system (default) event loop.
|
static |
Creates the system (default) event loop.
Referenced by create_system().
|
static |
Destroys the system (default) event loop.
Referenced by destroy_system().
| result< void > idfxx::event_loop::try_listener_remove | ( | listener_handle | handle | ) |
Removes a listener by handle.
| handle | The listener handle to remove. |
Referenced by listener_remove().
|
static |
Creates a user event loop without a dedicated task.
Events must be dispatched manually via user_event_loop::try_run().
| queue_size | Maximum number of events in the queue. |
Referenced by make_user(), and make_user().
|
static |
Creates a user 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. |
|
inline |
Posts a typed event with a timeout.
| IdEnum | The event ID enum type. |
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| base | The event base. |
| id | The event ID. |
| data | Event data. |
| size | Size of the event data. |
| timeout | Maximum time to wait for space in the event queue. |
Definition at line 550 of file event.hpp.
References idfxx::event_base< IdEnum >::idf_base(), idfxx::chrono::ticks(), idfxx::timeout, and idfxx::wrap().
|
inline |
Posts a typed event, waiting indefinitely.
| IdEnum | The event ID enum type. |
| base | The event base. |
| id | The event ID. |
| data | Optional event data. |
| size | Size of the event data. |
Definition at line 529 of file event.hpp.
References idfxx::event_base< IdEnum >::idf_base(), and idfxx::wrap().
Referenced by post(), post(), post(), post(), try_post(), and try_post().
|
inline |
Posts a typed event via event_type with a timeout.
| IdEnum | The event ID enum type. |
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| event | The event type (base + id). |
| data | Event data. |
| size | Size of the event data. |
| timeout | Maximum time to wait for space in the event queue. |
Definition at line 591 of file event.hpp.
References idfxx::event_type< IdEnum >::base, idfxx::event_type< IdEnum >::id, idfxx::timeout, and try_post().
|
inline |
Posts a typed event via event_type, waiting indefinitely.
| IdEnum | The event ID enum type. |
| event | The event type (base + id). |
| data | Optional event data. |
| size | Size of the event data. |
Definition at line 574 of file event.hpp.
References idfxx::event_type< IdEnum >::base, idfxx::event_type< IdEnum >::id, and try_post().