Loading...
Searching...
No Matches
dpl_eventq.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#include <dpl/dpl_types.h>
20
21#include "os/os_eventq.h"
22#include "uwb_core.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
31struct dpl_event {
32 struct os_event ev;
33};
34
38struct dpl_eventq {
39 struct os_eventq evq;
40};
41
45typedef void dpl_event_fn(struct dpl_event *ev);
46
54static inline void dpl_event_init(struct dpl_event *ev, dpl_event_fn * fn,
55 void *arg)
56{
57 os_event_init(&ev->ev, (os_event_fn*) fn, arg);
58}
59
67static inline bool dpl_event_is_queued(struct dpl_event *ev)
68{
69 return os_event_is_queued(&ev->ev);
70}
71
77static inline void *dpl_event_get_arg(struct dpl_event *ev)
78{
79 return os_event_get_arg(&ev->ev);
80}
81
88static inline void dpl_event_set_arg(struct dpl_event *ev, void *arg)
89{
90 os_event_set_arg(&ev->ev, arg);
91}
92
98static inline void dpl_event_run(struct dpl_event *ev)
99{
100 os_event_run(&ev->ev);
101}
102
108static inline void dpl_eventq_init(struct dpl_eventq *evq)
109{
110 os_eventq_init(&evq->evq);
111}
112
118static inline int dpl_eventq_inited(struct dpl_eventq *evq)
119{
120 return os_eventq_inited(&evq->evq);
121}
122
130static inline void dpl_eventq_deinit(struct dpl_eventq *evq)
131{
132 (void) evq;
133 /* Can't deinit an eventq in RIOT */
134}
135
143static inline struct dpl_event * dpl_eventq_get(struct dpl_eventq *evq)
144{
145 return (struct dpl_event *) os_eventq_get(&evq->evq, DPL_WAIT_FOREVER);
146}
147
153static inline struct dpl_event * dpl_eventq_get_no_wait(struct dpl_eventq *evq)
154{
155 return (struct dpl_event *) os_eventq_get_no_wait(&evq->evq);
156}
157
164static inline void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_event *ev)
165{
166 os_eventq_put(&evq->evq, &ev->ev);
167}
168
175static inline void dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_event *ev)
176{
177 os_eventq_remove(&evq->evq, &ev->ev);
178}
179
185static inline void dpl_eventq_run(struct dpl_eventq *evq)
186{
187 os_eventq_run(&evq->evq);
188}
189
197static inline bool dpl_eventq_is_empty(struct dpl_eventq *evq)
198{
199 return os_eventq_is_empty(&evq->evq);
200}
201
210static inline struct dpl_eventq * dpl_eventq_dflt_get(void)
211{
212 return (struct dpl_eventq *) uwb_core_get_eventq();
213}
214
215#ifdef __cplusplus
216}
217#endif
static struct dpl_eventq * dpl_eventq_dflt_get(void)
Retrieves the default event queue.
Definition dpl_eventq.h:210
static void * dpl_event_get_arg(struct dpl_event *ev)
Runs an event.
Definition dpl_eventq.h:77
static void dpl_event_run(struct dpl_event *ev)
Runs an event.
Definition dpl_eventq.h:98
static bool dpl_eventq_is_empty(struct dpl_eventq *evq)
Check if queue is empty.
Definition dpl_eventq.h:197
static void dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_event *ev)
Remove an event from the queue.
Definition dpl_eventq.h:175
static int dpl_eventq_inited(struct dpl_eventq *evq)
Check whether the event queue is initialized.
Definition dpl_eventq.h:118
static void dpl_eventq_run(struct dpl_eventq *evq)
Gets and runs an event from the queue callback.
Definition dpl_eventq.h:185
static struct dpl_event * dpl_eventq_get(struct dpl_eventq *evq)
Get next event from event queue, blocking.
Definition dpl_eventq.h:143
void dpl_event_fn(struct dpl_event *ev)
dpl event callback function
Definition dpl_eventq.h:45
static void dpl_event_set_arg(struct dpl_event *ev, void *arg)
Set the vent arg.
Definition dpl_eventq.h:88
static void dpl_event_init(struct dpl_event *ev, dpl_event_fn *fn, void *arg)
Init a event.
Definition dpl_eventq.h:54
static void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_event *ev)
Put an event on the event queue.
Definition dpl_eventq.h:164
static struct dpl_event * dpl_eventq_get_no_wait(struct dpl_eventq *evq)
Get next event from event queue, non-blocking.
Definition dpl_eventq.h:153
static void dpl_eventq_deinit(struct dpl_eventq *evq)
Deinitialize an event queue.
Definition dpl_eventq.h:130
static void dpl_eventq_init(struct dpl_eventq *evq)
Initialize the event queue.
Definition dpl_eventq.h:108
static bool dpl_event_is_queued(struct dpl_event *ev)
Check if event is in queue.
Definition dpl_eventq.h:67
uwb-core DPL (Decawave Porting Layer) types
mynewt-core event and event queue abstraction
static bool os_eventq_is_empty(struct os_eventq *evq)
Check if queue is empty.
Definition os_eventq.h:223
static struct os_event * os_eventq_get_no_wait(struct os_eventq *evq)
Get next event from event queue, non-blocking.
Definition os_eventq.h:174
static void os_event_init(struct os_event *ev, os_event_fn *fn, void *arg)
Init a event.
Definition os_eventq.h:56
static void os_event_set_arg(struct os_event *ev, void *arg)
Set the event argument.
Definition os_eventq.h:96
static int os_eventq_inited(struct os_eventq *evq)
Check whether the event queue is initialized.
Definition os_eventq.h:126
static struct os_event * os_eventq_get(struct os_eventq *evq, os_time_t tmo)
Get next event from event queue.
Definition os_eventq.h:152
static void os_eventq_remove(struct os_eventq *evq, struct os_event *ev)
Remove an event from the queue.
Definition os_eventq.h:200
static bool os_event_is_queued(struct os_event *ev)
Check if event is in queue.
Definition os_eventq.h:75
void os_event_fn(struct os_event *ev)
Event callback function.
Definition os_eventq.h:47
static void os_event_run(struct os_event *ev)
Runs an event.
Definition os_eventq.h:106
static void os_eventq_init(struct os_eventq *evq)
Initialize the event queue.
Definition os_eventq.h:116
static void os_eventq_put(struct os_eventq *evq, struct os_event *ev)
Put an event on the event queue.
Definition os_eventq.h:189
static void * os_event_get_arg(struct os_event *ev)
Returns event argument.
Definition os_eventq.h:85
static void os_eventq_run(struct os_eventq *evq)
Gets and runs an event from the queue callback.
Definition os_eventq.h:210
dpl event wrapper
Definition dpl_eventq.h:31
struct os_event ev
the event
Definition dpl_eventq.h:32
dpl event queue wrapper
Definition dpl_eventq.h:38
struct os_eventq evq
the event queue
Definition dpl_eventq.h:39
Event wrapper.
Definition os_eventq.h:31
Event queue wrapper.
Definition os_eventq.h:40
event_queue_t * uwb_core_get_eventq(void)
Retrieves the default event queue.