The Mail class allows you to control, send, receive or wait for mail. More...
#include <Mail.h>
Public Member Functions | |
Mail () | |
Create and initialize Mail queue. More... | |
bool | empty () const |
Check if the mail queue is empty. More... | |
bool | full () const |
Check if the mail queue is full. More... | |
T * | alloc (MBED_UNUSED uint32_t millisec=0) |
Allocate a memory block of type T, without blocking. More... | |
T * | alloc_for (uint32_t millisec) |
Allocate a memory block of type T, optionally blocking. More... | |
T * | alloc_until (uint64_t millisec) |
Allocate a memory block of type T, blocking. More... | |
T * | calloc (MBED_UNUSED uint32_t millisec=0) |
Allocate a memory block of type T, and set memory block to zero. More... | |
T * | calloc_for (uint32_t millisec) |
Allocate a memory block of type T, optionally blocking, and set memory block to zero. More... | |
T * | calloc_until (uint64_t millisec) |
Allocate a memory block of type T, blocking, and set memory block to zero. More... | |
osStatus | put (T *mptr) |
Put a mail in the queue. More... | |
osEvent | get (uint32_t millisec=osWaitForever) |
Get a mail from the queue. More... | |
osStatus | free (T *mptr) |
Free a memory block from a mail. More... | |
The Mail class allows you to control, send, receive or wait for mail.
A mail is a memory block that is sent to a thread or interrupt service routine (ISR).
T | Data type of a single mail message element. |
queue_sz | Maximum number of mail messages in queue. |
( | ) |
T* alloc | ( | MBED_UNUSED uint32_t | millisec = 0 | ) |
Allocate a memory block of type T, without blocking.
millisec | Not used (see note). |
T* alloc_for | ( | uint32_t | millisec | ) |
Allocate a memory block of type T, optionally blocking.
millisec | Timeout value, or osWaitForever. |
T* alloc_until | ( | uint64_t | millisec | ) |
Allocate a memory block of type T, blocking.
millisec | Absolute timeout time, referenced to Kernel::get_ms_count(). |
T* calloc | ( | MBED_UNUSED uint32_t | millisec = 0 | ) |
Allocate a memory block of type T, and set memory block to zero.
millisec | Not used (see note). |
T* calloc_for | ( | uint32_t | millisec | ) |
Allocate a memory block of type T, optionally blocking, and set memory block to zero.
millisec | Timeout value, or osWaitForever. |
T* calloc_until | ( | uint64_t | millisec | ) |
Allocate a memory block of type T, blocking, and set memory block to zero.
millisec | Absolute timeout time, referenced to Kernel::get_ms_count(). |
bool empty | ( | ) | const |
osStatus free | ( | T * | mptr | ) |
bool full | ( | ) | const |
osEvent get | ( | uint32_t | millisec = osWaitForever | ) |
Get a mail from the queue.
millisec | Timeout value (default: osWaitForever). |
osEventMessage | Message received. |
osOK | No mail is available (and no timeout was specified). |
osEventTimeout | No mail has arrived during the given timeout period. |
osErrorParameter | A parameter is invalid or outside of a permitted range. |
osStatus put | ( | T * | mptr | ) |
Put a mail in the queue.
mptr | Memory block previously allocated with Mail::alloc or Mail::calloc. |