Mailboxes

Mailbox implementation. More...

Detailed Description

Files

file  mbox.h
 Mailbox API.
 

Data Structures

struct  mbox_t
 Mailbox struct definition. More...
 

Macros

#define MBOX_INIT(queue, queue_size)   {{0}, {0}, CIB_INIT(queue_size), queue}
 Static initializer for mbox objects.
 

Enumerations

enum  { NON_BLOCKING = 0, BLOCKING }
 

Functions

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...
 

Enumeration Type Documentation

anonymous enum
Enumerator
NON_BLOCKING 

non-blocking mode

BLOCKING 

blocking mode

Definition at line 46 of file mbox.h.

Function Documentation

int _mbox_get ( mbox_t mbox,
msg_t msg,
int  blocking 
)

If the mailbox is empty, this fuction will return right away.

int _mbox_put ( mbox_t mbox,
msg_t msg,
int  blocking 
)

If the mailbox is full, this fuction will return right away.

static void mbox_get ( mbox_t mbox,
msg_t msg 
)
inlinestatic

If the mailbox is empty, this fuction will block until a message becomes available.

Parameters
[in]mboxptr to mailbox to operate on
[in]msgptr to storage for retrieved message

Definition at line 137 of file mbox.h.

static void mbox_init ( mbox_t mbox,
msg_t queue,
unsigned int  queue_size 
)
inlinestatic
Note
The message queue size must be a power of two!
Parameters
[in]mboxptr to mailbox to initialize
[in]queuearray of msg_t used as queue
[in]queue_sizenumber of msg_t objects in queue

Definition at line 60 of file mbox.h.

static void mbox_put ( mbox_t mbox,
msg_t msg 
)
inlinestatic

If the mailbox is full, this fuction will block until space becomes available.

Parameters
[in]mboxptr to mailbox to operate on
[in]msgptr to message that will be copied into mailbox

Definition at line 107 of file mbox.h.

static int mbox_try_get ( mbox_t mbox,
msg_t msg 
)
inlinestatic

If the mailbox is empty, this fuction will return right away.

Parameters
[in]mboxptr to mailbox to operate on
[in]msgptr to storage for retrieved message
Returns
1 if msg could be retrieved
0 otherwise

Definition at line 153 of file mbox.h.

static int mbox_try_put ( mbox_t mbox,
msg_t msg 
)
inlinestatic

If the mailbox is full, this fuction will return right away.

Parameters
[in]mboxptr to mailbox to operate on
[in]msgptr to message that will be copied into mailbox
Returns
1 if msg could be delivered
0 otherwise

Definition at line 123 of file mbox.h.