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
20#ifndef DPL_DPL_EVENTQ_H
21#define DPL_DPL_EVENTQ_H
22
23#include <dpl/dpl_types.h>
24
25#include "os/os_eventq.h"
26#include "uwb_core.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
35struct dpl_event {
36 struct os_event ev;
37};
38
42struct dpl_eventq {
43 struct os_eventq evq;
44};
45
49typedef void dpl_event_fn(struct dpl_event *ev);
50
58static inline void dpl_event_init(struct dpl_event *ev, dpl_event_fn * fn,
59 void *arg)
60{
61 os_event_init(&ev->ev, (os_event_fn*) fn, arg);
62}
63
71static inline bool dpl_event_is_queued(struct dpl_event *ev)
72{
73 return os_event_is_queued(&ev->ev);
74}
75
81static inline void *dpl_event_get_arg(struct dpl_event *ev)
82{
83 return os_event_get_arg(&ev->ev);
84}
85
92static inline void dpl_event_set_arg(struct dpl_event *ev, void *arg)
93{
94 os_event_set_arg(&ev->ev, arg);
95}
96
102static inline void dpl_event_run(struct dpl_event *ev)
103{
104 os_event_run(&ev->ev);
105}
106
112static inline void dpl_eventq_init(struct dpl_eventq *evq)
113{
114 os_eventq_init(&evq->evq);
115}
116
122static inline int dpl_eventq_inited(struct dpl_eventq *evq)
123{
124 return os_eventq_inited(&evq->evq);
125}
126
134static inline void dpl_eventq_deinit(struct dpl_eventq *evq)
135{
136 (void) evq;
137 /* Can't deinit an eventq in RIOT */
138}
139
147static inline struct dpl_event * dpl_eventq_get(struct dpl_eventq *evq)
148{
149 return (struct dpl_event *) os_eventq_get(&evq->evq, DPL_WAIT_FOREVER);
150}
151
157static inline struct dpl_event * dpl_eventq_get_no_wait(struct dpl_eventq *evq)
158{
159 return (struct dpl_event *) os_eventq_get_no_wait(&evq->evq);
160}
161
168static inline void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_event *ev)
169{
170 os_eventq_put(&evq->evq, &ev->ev);
171}
172
179static inline void dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_event *ev)
180{
181 os_eventq_remove(&evq->evq, &ev->ev);
182}
183
189static inline void dpl_eventq_run(struct dpl_eventq *evq)
190{
191 os_eventq_run(&evq->evq);
192}
193
201static inline bool dpl_eventq_is_empty(struct dpl_eventq *evq)
202{
203 return os_eventq_is_empty(&evq->evq);
204}
205
214static inline struct dpl_eventq * dpl_eventq_dflt_get(void)
215{
216 return (struct dpl_eventq *) uwb_core_get_eventq();
217}
218
219#ifdef __cplusplus
220}
221#endif
222
223#endif /* DPL_DPL_EVENTQ_H */
static struct dpl_eventq * dpl_eventq_dflt_get(void)
Retrieves the default event queue.
Definition dpl_eventq.h:214
static void * dpl_event_get_arg(struct dpl_event *ev)
Runs an event.
Definition dpl_eventq.h:81
static void dpl_event_run(struct dpl_event *ev)
Runs an event.
Definition dpl_eventq.h:102
static bool dpl_eventq_is_empty(struct dpl_eventq *evq)
Check if queue is empty.
Definition dpl_eventq.h:201
static void dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_event *ev)
Remove an event from the queue.
Definition dpl_eventq.h:179
static int dpl_eventq_inited(struct dpl_eventq *evq)
Check whether the event queue is initialized.
Definition dpl_eventq.h:122
static void dpl_eventq_run(struct dpl_eventq *evq)
Gets and runs an event from the queue callback.
Definition dpl_eventq.h:189
static struct dpl_event * dpl_eventq_get(struct dpl_eventq *evq)
Get next event from event queue, blocking.
Definition dpl_eventq.h:147
void dpl_event_fn(struct dpl_event *ev)
dpl event callback function
Definition dpl_eventq.h:49
static void dpl_event_set_arg(struct dpl_event *ev, void *arg)
Set the vent arg.
Definition dpl_eventq.h:92
static void dpl_event_init(struct dpl_event *ev, dpl_event_fn *fn, void *arg)
Init a event.
Definition dpl_eventq.h:58
static void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_event *ev)
Put an event on the event queue.
Definition dpl_eventq.h:168
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:157
static void dpl_eventq_deinit(struct dpl_eventq *evq)
Deinitialize an event queue.
Definition dpl_eventq.h:134
static void dpl_eventq_init(struct dpl_eventq *evq)
Initialize the event queue.
Definition dpl_eventq.h:112
static bool dpl_event_is_queued(struct dpl_event *ev)
Check if event is in queue.
Definition dpl_eventq.h:71
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:227
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:178
static void os_event_init(struct os_event *ev, os_event_fn *fn, void *arg)
Init a event.
Definition os_eventq.h:60
static void os_event_set_arg(struct os_event *ev, void *arg)
Set the event argument.
Definition os_eventq.h:100
static int os_eventq_inited(struct os_eventq *evq)
Check whether the event queue is initialized.
Definition os_eventq.h:130
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:156
static void os_eventq_remove(struct os_eventq *evq, struct os_event *ev)
Remove an event from the queue.
Definition os_eventq.h:204
static bool os_event_is_queued(struct os_event *ev)
Check if event is in queue.
Definition os_eventq.h:79
void os_event_fn(struct os_event *ev)
Event callback function.
Definition os_eventq.h:51
static void os_event_run(struct os_event *ev)
Runs an event.
Definition os_eventq.h:110
static void os_eventq_init(struct os_eventq *evq)
Initialize the event queue.
Definition os_eventq.h:120
static void os_eventq_put(struct os_eventq *evq, struct os_event *ev)
Put an event on the event queue.
Definition os_eventq.h:193
static void * os_event_get_arg(struct os_event *ev)
Returns event argument.
Definition os_eventq.h:89
static void os_eventq_run(struct os_eventq *evq)
Gets and runs an event from the queue callback.
Definition os_eventq.h:214
dpl event wrapper
Definition dpl_eventq.h:35
struct os_event ev
the envent
Definition dpl_eventq.h:36
dpl event queue wrapper
Definition dpl_eventq.h:42
struct os_eventq evq
the event queue
Definition dpl_eventq.h:43
Event wrapper.
Definition os_eventq.h:35
Event queue wrapper.
Definition os_eventq.h:44
event_queue_t * uwb_core_get_eventq(void)
Retrieves the default event queue.