From 7a66f1cc4260474b69e5e6b8e6eacb145d950791 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 4 Oct 2023 13:21:05 +0200 Subject: [PATCH] sys/event/timeout: add event_timeout_is_pending() --- sys/include/event/timeout.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/include/event/timeout.h b/sys/include/event/timeout.h index eee2b881cf..3f7b9b7f46 100644 --- a/sys/include/event/timeout.h +++ b/sys/include/event/timeout.h @@ -107,6 +107,18 @@ void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout); */ void event_timeout_clear(event_timeout_t *event_timeout); +/** + * @brief Check if a timeout event is scheduled to be executed in the future + * + * @param[in] event_timeout event_timout context object to use + * @return true if the event is scheduled, false otherwise + */ +static inline bool event_timeout_is_pending(const event_timeout_t *event_timeout) +{ + return ztimer_is_set(event_timeout->clock, &event_timeout->timer) + || event_is_queued(event_timeout->queue, event_timeout->event); +} + #ifdef __cplusplus } #endif