Loading...
Searching...
No Matches
timeout.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Inria
3 * 2017 Freie Universität Berlin
4 * 2017 Kaspar Schleiser <kaspar@schleiser.de>
5 *
6 * This file is subject to the terms and conditions of the GNU Lesser
7 * General Public License v2.1. See the file LICENSE in the top level
8 * directory for more details.
9 */
10
37#ifndef EVENT_TIMEOUT_H
38#define EVENT_TIMEOUT_H
39
40#include "event.h"
41#include "ztimer.h"
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
56
66 event_queue_t *queue, event_t *event);
67
68#if IS_USED(MODULE_EVENT_TIMEOUT) || DOXYGEN
79 event_t *event);
80#endif
81
96void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout);
97
109
116static inline bool event_timeout_is_pending(const event_timeout_t *event_timeout)
117{
118 if (event_timeout->clock == NULL || event_timeout->queue == NULL ||
119 event_timeout->event == NULL) {
120 return false;
121 }
122
123 return ztimer_is_set(event_timeout->clock, &event_timeout->timer)
124 || event_is_queued(event_timeout->queue, event_timeout->event);
125}
126
127#ifdef __cplusplus
128}
129#endif
130#endif /* EVENT_TIMEOUT_H */
void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout)
Set a timeout.
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.
Definition timeout.h:116
void event_timeout_init(event_timeout_t *event_timeout, event_queue_t *queue, event_t *event)
Initialize timeout event object.
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_clear(event_timeout_t *event_timeout)
Clear a timeout event.
bool event_is_queued(const event_queue_t *queue, const event_t *event)
Check if an event is already queued.
unsigned ztimer_is_set(const ztimer_clock_t *clock, const ztimer_t *timer)
Check if a timer is currently active.
event queue structure
Definition event.h:156
Timeout Event structure.
Definition timeout.h:50
ztimer_t timer
ztimer object used for timeout
Definition timeout.h:52
event_t * event
event to post after timeout
Definition timeout.h:54
event_queue_t * queue
event queue to post event to
Definition timeout.h:53
ztimer_clock_t * clock
ztimer clock to use
Definition timeout.h:51
event structure
Definition event.h:148
ztimer device structure
Definition ztimer.h:369
ztimer structure
Definition ztimer.h:318
ztimer API