evtimer_mbox.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2020 Simon Brummer <simon.brummer@posteo.de>
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
18 #include "assert.h"
19 #include "msg.h"
20 #include "mbox.h"
21 #include "evtimer.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
30 typedef struct {
35 
47 static inline void evtimer_add_mbox(evtimer_t *evtimer, evtimer_mbox_event_t *event, mbox_t *mbox)
48 {
49  assert(evtimer);
50  assert(event);
51  assert(mbox);
52  event->mbox = mbox;
53  evtimer_add(evtimer, &(event->event));
54 }
55 
64 {
65  assert(event);
67  mbox_try_put(mbevent->mbox, &(mbevent->msg));
68 }
69 
77 static inline void evtimer_init_mbox(evtimer_t *evtimer)
78 {
79  assert(evtimer);
81 }
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:143
evtimer API definitions
static int mbox_try_put(mbox_t *mbox, msg_t *msg)
Add message to mailbox.
Definition: mbox.h:123
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:63
static void evtimer_init_mbox(evtimer_t *evtimer)
Initializes event timer for mbox events.
Definition: evtimer_mbox.h:77
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:47
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
Adds event to an event timer.
Mailbox API.
event structure
Definition: event.h:142
Generic event.
Definition: evtimer.h:52
Message box event definition.
Definition: evtimer_mbox.h:30
msg_t msg
message to store in mbox on event
Definition: evtimer_mbox.h:32
evtimer_event_t event
event base class
Definition: evtimer_mbox.h:31
mbox_t * mbox
mbox the IPC message shall be stored
Definition: evtimer_mbox.h:33
Event timer.
Definition: evtimer.h:65
Mailbox struct definition.
Definition: mbox.h:37
Describes a message object which can be sent between threads.
Definition: msg.h:192