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 */
91 
evtimer_t
Event timer.
Definition: evtimer.h:79
evtimer_add
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
Adds event to an event timer.
assert
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:104
evtimer_mbox_event_t
Message box event definition.
Definition: evtimer_mbox.h:33
mbox_try_put
static int mbox_try_put(mbox_t *mbox, msg_t *msg)
Add message to mailbox.
Definition: mbox.h:127
assert.h
POSIX.1-2008 compliant version of the assert macro.
evtimer_add_mbox
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
event
event structure
Definition: event.h:142
evtimer_mbox_event_t::mbox
mbox_t * mbox
mbox the IPC message shall be stored
Definition: evtimer_mbox.h:36
_evtimer_mbox_handler
static void _evtimer_mbox_handler(evtimer_event_t *event)
Event handler for mbox events.
Definition: evtimer_mbox.h:66
msg.h
Messaging API for inter process communication.
evtimer_mbox_event_t::msg
msg_t msg
message to store in mbox on event
Definition: evtimer_mbox.h:35
mbox_t
Mailbox struct definition.
Definition: mbox.h:41
mbox.h
Mailbox API.
evtimer_init_mbox
static void evtimer_init_mbox(evtimer_t *evtimer)
Initializes event timer for mbox events.
Definition: evtimer_mbox.h:80
evtimer.h
evtimer API definitions
evtimer_mbox_event_t::event
evtimer_event_t event
event base class
Definition: evtimer_mbox.h:34
evtimer_event
Generic event.
Definition: evtimer.h:66
msg_t
Describes a message object which can be sent between threads.
Definition: msg.h:185
evtimer_init
void evtimer_init(evtimer_t *evtimer, evtimer_callback_t handler)
Initializes an event timer.