Provides functionality to trigger events after timeout. More...
Provides functionality to trigger events after timeout.
event_timeout intentionally doesn't extend event structures in order to support events that are integrated in larger structs intrusively.
Example:
Event Timeout API
Definition in file timeout.h.
Go to the source code of this file.
Data Structures | |
struct | event_timeout_t |
Timeout Event structure. More... | |
void | event_timeout_ztimer_init (event_timeout_t *event_timeout, ztimer_clock_t *clock, event_queue_t *queue, event_t *event) |
Initialize timeout event object. | |
void | event_timeout_init (event_timeout_t *event_timeout, event_queue_t *queue, event_t *event) |
Initialize timeout event object. | |
void | event_timeout_set (event_timeout_t *event_timeout, uint32_t timeout) |
Set a timeout. | |
void | event_timeout_clear (event_timeout_t *event_timeout) |
Clear a timeout event. | |
static bool | event_timeout_is_pending (const event_timeout_t *event_timeout) |
Check if a timeout event is scheduled to be executed in the future. | |
void event_timeout_clear | ( | event_timeout_t * | event_timeout | ) |
Clear a timeout event.
Calling this function will cancel the timeout by removing its underlying timer. If the timer has already fired before calling this function, the connected event will be put already into the given event queue and this function does not have any effect.
[in] | event_timeout | event_timeout context object to use |
void event_timeout_init | ( | event_timeout_t * | event_timeout, |
event_queue_t * | queue, | ||
event_t * | event | ||
) |
Initialize timeout event object.
[in] | event_timeout | event_timeout object to initialize |
[in] | queue | queue that the timed-out event will be added to |
[in] | event | event to add to queue after timeout |
|
inlinestatic |
void event_timeout_set | ( | event_timeout_t * | event_timeout, |
uint32_t | timeout | ||
) |
Set a timeout.
This will make the event as configured in event_timeout
be triggered after timeout
microseconds (if using xtimer) or the ztimer_clock_t ticks.
[in] | event_timeout | event_timout context object to use |
[in] | timeout | timeout in microseconds or the ztimer_clock_t ticks units |
void event_timeout_ztimer_init | ( | event_timeout_t * | event_timeout, |
ztimer_clock_t * | clock, | ||
event_queue_t * | queue, | ||
event_t * | event | ||
) |
Initialize timeout event object.
[in] | event_timeout | event_timeout object to initialize |
[in] | clock | the clock backend, eg: ZTIMER_USEC, ZTIMER_MSEC |
[in] | queue | queue that the timed-out event will be added to |
[in] | event | event to add to queue after timeout |