110#if IS_USED(MODULE_ZTIMER)
118#ifndef THREAD_FLAG_EVENT
122#define THREAD_FLAG_EVENT (0x1)
128#define EVENT_QUEUE_INIT { .waiter = thread_get_active() }
133#define EVENT_QUEUE_INIT_DETACHED { .waiter = NULL }
172 assert(queues && n_queues);
174 for (
size_t i = 0; i < n_queues; i++) {
175 memset(&queues[i],
'\0',
sizeof(queues[0]));
202 for (
size_t i = 0; i < n_queues; i++) {
203 memset(&queues[i],
'\0',
sizeof(queues[0]));
232 for (
size_t i = 0; i < n_queues; i++) {
233 assert(queues[i].waiter == NULL);
359#if IS_USED(MODULE_XTIMER) || defined(DOXYGEN)
389#if IS_USED(MODULE_ZTIMER) || defined(DOXYGEN)
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
static thread_t * thread_get_active(void)
Returns a pointer to the Thread Control Block of the currently running thread.
static void event_loop_multi(event_queue_t *queues, size_t n_queues)
Simple event loop with multiple queues.
void event_post(event_queue_t *queue, event_t *event)
Queue an event.
static event_t * event_wait(event_queue_t *queue)
Get next event from event queue, blocking.
static void event_loop(event_queue_t *queue)
Simple event loop.
event_t * event_wait_timeout_ztimer(event_queue_t *queue, ztimer_clock_t *clock, uint32_t timeout)
Get next event from event queue, blocking until timeout expires.
static void event_queue_init(event_queue_t *queue)
Initialize an event queue.
void(* event_handler_t)(event_t *)
event handler type definition
void event_cancel(event_queue_t *queue, event_t *event)
Cancel a queued event.
struct PTRTAG event_queue_t
event queue structure
static void event_queue_init_detached(event_queue_t *queue)
Initialize an event queue not binding it to a thread.
static void event_queue_claim(event_queue_t *queue)
Bind an event queue to the calling thread.
static void event_queues_claim(event_queue_t *queues, size_t n_queues)
Bind an array of event queues to the calling thread.
void event_sync(event_queue_t *queue)
Synchronize with the last event on the queue.
static void event_queues_init_detached(event_queue_t *queues, size_t n_queues)
Initialize an array of event queues not binding it to a thread.
event_t * event_wait_multi(event_queue_t *queues, size_t n_queues)
Get next event from the given event queues, blocking.
event_t * event_wait_timeout(event_queue_t *queue, uint32_t timeout)
Get next event from event queue, blocking until timeout expires.
static void event_queues_init(event_queue_t *queues, size_t n_queues)
Initialize an array of event queues.
event_t * event_get(event_queue_t *queue)
Get next event from event queue, non-blocking.
bool event_is_queued(const event_queue_t *queue, const event_t *event)
Check if an event is already queued.
event_t * event_wait_timeout64(event_queue_t *queue, uint64_t timeout)
Get next event from event queue, blocking until timeout expires.
thread_t * waiter
thread owning event queue
clist_node_t event_list
list of queued events
thread_t holds thread's context data.
event_handler_t handler
pointer to event handler function
clist_node_t list_node
event queue list entry