evtimer_mbox.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Simon Brummer <simon.brummer@posteo.de>
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 
18 #ifndef EVTIMER_MBOX_H
19 #define EVTIMER_MBOX_H
20 
21 #include "assert.h"
22 #include "msg.h"
23 #include "mbox.h"
24 #include "evtimer.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
33 typedef struct {
38 
50 static inline void evtimer_add_mbox(evtimer_t *evtimer, evtimer_mbox_event_t *event, mbox_t *mbox)
51 {
52  assert(evtimer);
53  assert(event);
54  assert(mbox);
55  event->mbox = mbox;
56  evtimer_add(evtimer, &(event->event));
57 }
58 
67 {
68  assert(event);
70  mbox_try_put(mbevent->mbox, &(mbevent->msg));
71 }
72 
80 static inline void evtimer_init_mbox(evtimer_t *evtimer)
81 {
82  assert(evtimer);
84 }
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif /* EVTIMER_MBOX_H */
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:104
evtimer API definitions
static int mbox_try_put(mbox_t *mbox, msg_t *msg)
Add message to mailbox.
Definition: mbox.h:127
void evtimer_init(evtimer_t *evtimer, evtimer_callback_t handler)
Initializes an event timer.
static void _evtimer_mbox_handler(evtimer_event_t *event)
Event handler for mbox events.
Definition: evtimer_mbox.h:66
static void evtimer_init_mbox(evtimer_t *evtimer)
Initializes event timer for mbox events.
Definition: evtimer_mbox.h:80
static void evtimer_add_mbox(evtimer_t *evtimer, evtimer_mbox_event_t *event, mbox_t *mbox)
Adds mbox event to an event timer.
Definition: evtimer_mbox.h:50
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
Adds event to an event timer.
Mailbox API.
event structure
Definition: event.h:147
Generic event.
Definition: evtimer.h:66
Message box event definition.
Definition: evtimer_mbox.h:33
msg_t msg
message to store in mbox on event
Definition: evtimer_mbox.h:35
evtimer_event_t event
event base class
Definition: evtimer_mbox.h:34
mbox_t * mbox
mbox the IPC message shall be stored
Definition: evtimer_mbox.h:36
Event timer.
Definition: evtimer.h:79
Mailbox struct definition.
Definition: mbox.h:41
Describes a message object which can be sent between threads.
Definition: msg.h:185