Mailbox implementation.
More...
Mailbox implementation.
|
#define | MBOX_INIT(queue, queue_size) |
| Static initializer for mbox objects. More...
|
|
|
static void | mbox_init (mbox_t *mbox, msg_t *queue, unsigned int queue_size) |
| Initialize mbox object. More...
|
|
int | _mbox_put (mbox_t *mbox, msg_t *msg, int blocking) |
| Add message to mailbox. More...
|
|
int | _mbox_get (mbox_t *mbox, msg_t *msg, int blocking) |
| Get message from mailbox. More...
|
|
static void | mbox_put (mbox_t *mbox, msg_t *msg) |
| Add message to mailbox. More...
|
|
static int | mbox_try_put (mbox_t *mbox, msg_t *msg) |
| Add message to mailbox. More...
|
|
static void | mbox_get (mbox_t *mbox, msg_t *msg) |
| Get message from mailbox. More...
|
|
static int | mbox_try_get (mbox_t *mbox, msg_t *msg) |
| Get message from mailbox. More...
|
|
static size_t | mbox_size (mbox_t *mbox) |
| Get mbox queue size (capacity) More...
|
|
static size_t | mbox_avail (mbox_t *mbox) |
| Get messages available in mbox. More...
|
|
◆ MBOX_INIT
#define MBOX_INIT |
( |
|
queue, |
|
|
|
queue_size |
|
) |
| |
Value: { \
{ 0 }, { 0 },
CIB_INIT(queue_size), queue \
}
Static initializer for mbox objects.
Definition at line 34 of file mbox.h.
◆ anonymous enum
Enumerator |
---|
NON_BLOCKING | non-blocking mode
|
BLOCKING | blocking mode
|
Definition at line 48 of file mbox.h.
◆ _mbox_get()
int _mbox_get |
( |
mbox_t * |
mbox, |
|
|
msg_t * |
msg, |
|
|
int |
blocking |
|
) |
| |
Get message from mailbox.
If the mailbox is empty, this function will return right away.
◆ _mbox_put()
int _mbox_put |
( |
mbox_t * |
mbox, |
|
|
msg_t * |
msg, |
|
|
int |
blocking |
|
) |
| |
Add message to mailbox.
If the mailbox is full, this function will return right away.
◆ mbox_avail()
static size_t mbox_avail |
( |
mbox_t * |
mbox | ) |
|
|
inlinestatic |
Get messages available in mbox.
Returns the number of messages that can be retrieved without blocking.
- Parameters
-
[in] | mbox | ptr to mailbox to operate on |
- Returns
- number of available messages
Definition at line 183 of file mbox.h.
◆ mbox_get()
Get message from mailbox.
If the mailbox is empty, this function will block until a message becomes available.
- Parameters
-
[in] | mbox | ptr to mailbox to operate on |
[in] | msg | ptr to storage for retrieved message |
Definition at line 141 of file mbox.h.
◆ mbox_init()
static void mbox_init |
( |
mbox_t * |
mbox, |
|
|
msg_t * |
queue, |
|
|
unsigned int |
queue_size |
|
) |
| |
|
inlinestatic |
Initialize mbox object.
- Note
- The message queue size must be a power of two!
- Parameters
-
[in] | mbox | ptr to mailbox to initialize |
[in] | queue | array of msg_t used as queue |
[in] | queue_size | number of msg_t objects in queue |
Definition at line 62 of file mbox.h.
◆ mbox_put()
Add message to mailbox.
If the mailbox is full, this function will block until space becomes available.
- Parameters
-
[in] | mbox | ptr to mailbox to operate on |
[in] | msg | ptr to message that will be copied into mailbox |
Definition at line 111 of file mbox.h.
◆ mbox_size()
static size_t mbox_size |
( |
mbox_t * |
mbox | ) |
|
|
inlinestatic |
Get mbox queue size (capacity)
- Parameters
-
[in] | mbox | ptr to mailbox to operate on |
- Returns
- size of mbox queue (or 0 if there's no queue)
Definition at line 169 of file mbox.h.
◆ mbox_try_get()
Get message from mailbox.
If the mailbox is empty, this function will return right away.
- Parameters
-
[in] | mbox | ptr to mailbox to operate on |
[in] | msg | ptr to storage for retrieved message |
- Returns
- 1 if msg could be retrieved
-
0 otherwise
Definition at line 157 of file mbox.h.
◆ mbox_try_put()
Add message to mailbox.
If the mailbox is full, this function will return right away.
- Parameters
-
[in] | mbox | ptr to mailbox to operate on |
[in] | msg | ptr to message that will be copied into mailbox |
- Returns
- 1 if msg could be delivered
-
0 otherwise
Definition at line 127 of file mbox.h.