Loading...
Searching...
No Matches
dpl_eventq.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Inria
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
21
22#include <dpl/dpl_types.h>
23
24#include "os/os_eventq.h"
25#include "uwb_core.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
34struct dpl_event {
35 struct os_event ev;
36};
37
41struct dpl_eventq {
42 struct os_eventq evq;
43};
44
48typedef void dpl_event_fn(struct dpl_event *ev);
49
57static inline void dpl_event_init(struct dpl_event *ev, dpl_event_fn * fn,
58 void *arg)
59{
60 os_event_init(&ev->ev, (os_event_fn*) fn, arg);
61}
62
70static inline bool dpl_event_is_queued(struct dpl_event *ev)
71{
72 return os_event_is_queued(&ev->ev);
73}
74
80static inline void *dpl_event_get_arg(struct dpl_event *ev)
81{
82 return os_event_get_arg(&ev->ev);
83}
84
91static inline void dpl_event_set_arg(struct dpl_event *ev, void *arg)
92{
93 os_event_set_arg(&ev->ev, arg);
94}
95
101static inline void dpl_event_run(struct dpl_event *ev)
102{
103 os_event_run(&ev->ev);
104}
105
111static inline void dpl_eventq_init(struct dpl_eventq *evq)
112{
113 os_eventq_init(&evq->evq);
114}
115
121static inline int dpl_eventq_inited(struct dpl_eventq *evq)
122{
123 return os_eventq_inited(&evq->evq);
124}
125
133static inline void dpl_eventq_deinit(struct dpl_eventq *evq)
134{
135 (void) evq;
136 /* Can't deinit an eventq in RIOT */
137}
138
146static inline struct dpl_event * dpl_eventq_get(struct dpl_eventq *evq)
147{
148 return (struct dpl_event *) os_eventq_get(&evq->evq, DPL_WAIT_FOREVER);
149}
150
156static inline struct dpl_event * dpl_eventq_get_no_wait(struct dpl_eventq *evq)
157{
158 return (struct dpl_event *) os_eventq_get_no_wait(&evq->evq);
159}
160
167static inline void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_event *ev)
168{
169 os_eventq_put(&evq->evq, &ev->ev);
170}
171
178static inline void dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_event *ev)
179{
180 os_eventq_remove(&evq->evq, &ev->ev);
181}
182
188static inline void dpl_eventq_run(struct dpl_eventq *evq)
189{
190 os_eventq_run(&evq->evq);
191}
192
200static inline bool dpl_eventq_is_empty(struct dpl_eventq *evq)
201{
202 return os_eventq_is_empty(&evq->evq);
203}
204
213static inline struct dpl_eventq * dpl_eventq_dflt_get(void)
214{
215 return (struct dpl_eventq *) uwb_core_get_eventq();
216}
217
218#ifdef __cplusplus
219}
220#endif
static struct dpl_eventq * dpl_eventq_dflt_get(void)
Retrieves the default event queue.
Definition dpl_eventq.h:213
static void * dpl_event_get_arg(struct dpl_event *ev)
Runs an event.
Definition dpl_eventq.h:80
static void dpl_event_run(struct dpl_event *ev)
Runs an event.
Definition dpl_eventq.h:101
static bool dpl_eventq_is_empty(struct dpl_eventq *evq)
Check if queue is empty.
Definition dpl_eventq.h:200
static void dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_event *ev)
Remove an event from the queue.
Definition dpl_eventq.h:178
static int dpl_eventq_inited(struct dpl_eventq *evq)
Check whether the event queue is initialized.
Definition dpl_eventq.h:121
static void dpl_eventq_run(struct dpl_eventq *evq)
Gets and runs an event from the queue callback.
Definition dpl_eventq.h:188
static struct dpl_event * dpl_eventq_get(struct dpl_eventq *evq)
Get next event from event queue, blocking.
Definition dpl_eventq.h:146
void dpl_event_fn(struct dpl_event *ev)
dpl event callback function
Definition dpl_eventq.h:48
static void dpl_event_set_arg(struct dpl_event *ev, void *arg)
Set the vent arg.
Definition dpl_eventq.h:91
static void dpl_event_init(struct dpl_event *ev, dpl_event_fn *fn, void *arg)
Init a event.
Definition dpl_eventq.h:57
static void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_event *ev)
Put an event on the event queue.
Definition dpl_eventq.h:167
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:156
static void dpl_eventq_deinit(struct dpl_eventq *evq)
Deinitialize an event queue.
Definition dpl_eventq.h:133
static void dpl_eventq_init(struct dpl_eventq *evq)
Initialize the event queue.
Definition dpl_eventq.h:111
static bool dpl_event_is_queued(struct dpl_event *ev)
Check if event is in queue.
Definition dpl_eventq.h:70
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:226
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:177
static void os_event_init(struct os_event *ev, os_event_fn *fn, void *arg)
Init a event.
Definition os_eventq.h:59
static void os_event_set_arg(struct os_event *ev, void *arg)
Set the event argument.
Definition os_eventq.h:99
static int os_eventq_inited(struct os_eventq *evq)
Check whether the event queue is initialized.
Definition os_eventq.h:129
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:155
static void os_eventq_remove(struct os_eventq *evq, struct os_event *ev)
Remove an event from the queue.
Definition os_eventq.h:203
static bool os_event_is_queued(struct os_event *ev)
Check if event is in queue.
Definition os_eventq.h:78
void os_event_fn(struct os_event *ev)
Event callback function.
Definition os_eventq.h:50
static void os_event_run(struct os_event *ev)
Runs an event.
Definition os_eventq.h:109
static void os_eventq_init(struct os_eventq *evq)
Initialize the event queue.
Definition os_eventq.h:119
static void os_eventq_put(struct os_eventq *evq, struct os_event *ev)
Put an event on the event queue.
Definition os_eventq.h:192
static void * os_event_get_arg(struct os_event *ev)
Returns event argument.
Definition os_eventq.h:88
static void os_eventq_run(struct os_eventq *evq)
Gets and runs an event from the queue callback.
Definition os_eventq.h:213
dpl event wrapper
Definition dpl_eventq.h:34
struct os_event ev
the event
Definition dpl_eventq.h:35
dpl event queue wrapper
Definition dpl_eventq.h:41
struct os_eventq evq
the event queue
Definition dpl_eventq.h:42
Event wrapper.
Definition os_eventq.h:34
Event queue wrapper.
Definition os_eventq.h:43
event_queue_t * uwb_core_get_eventq(void)
Retrieves the default event queue.