The Mail class allows you to control, send, receive or wait for mail. More...
#include <Mail.h>
Public Member Functions | |
Mail ()=default | |
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 * | try_alloc () |
Allocate a memory block of type T, without blocking. More... | |
T * | try_alloc_for (Kernel::Clock::duration_u32 rel_time) |
Allocate a memory block of type T, optionally blocking. More... | |
T * | alloc_for (uint32_t millisec) |
Allocate a memory block of type T, optionally blocking. More... | |
T * | try_alloc_until (Kernel::Clock::time_point abs_time) |
Allocate a memory block of type T, 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 * | try_calloc () |
Allocate a memory block of type T, and set memory block to zero. More... | |
T * | try_calloc_for (Kernel::Clock::duration_u32 rel_time) |
Allocate a memory block of type T, optionally blocking, 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 * | try_calloc_until (Kernel::Clock::time_point abs_time) |
Allocate a memory block of type T, 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... | |
T * | try_get () |
Get a mail from the queue. More... | |
T * | try_get_for (Kernel::Clock::duration_u32 rel_time) |
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. |
|
default |
Create and initialize Mail 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. |
5s
rather than 5000
. T* alloc_until | ( | uint64_t | millisec | ) |
Allocate a memory block of type T, blocking.
millisec | Absolute timeout time, referenced to Kernel::get_ms_count(). |
Kernel::Clock::now() + 5s
rather than Kernel::get_ms_count() + 5000
. 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. |
5s
rather than 5000
. 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(). |
Kernel::Clock::now() + 5s
rather than Kernel::get_ms_count() + 5000
. bool empty | ( | ) | const |
osStatus free | ( | T * | mptr | ) |
bool full | ( | ) | const |
osEvent get | ( | uint32_t | millisec = osWaitForever | ) |
Get a mail from the queue.
rel_time | Timeout value (default: Kernel::wait_for_u32_forever). |
osStatus put | ( | T * | mptr | ) |
Put a mail in the queue.
mptr | Memory block previously allocated with Mail::alloc or Mail::calloc. |
T* try_alloc | ( | ) |
Allocate a memory block of type T, without blocking.
T* try_alloc_for | ( | Kernel::Clock::duration_u32 | rel_time | ) |
Allocate a memory block of type T, optionally blocking.
rel_time | Timeout value, or Kernel::wait_for_u32_forever. |
T* try_alloc_until | ( | Kernel::Clock::time_point | abs_time | ) |
Allocate a memory block of type T, blocking.
abs_time | Absolute timeout time, referenced to Kernel::Clock. |
T* try_calloc | ( | ) |
Allocate a memory block of type T, and set memory block to zero.
T* try_calloc_for | ( | Kernel::Clock::duration_u32 | rel_time | ) |
Allocate a memory block of type T, optionally blocking, and set memory block to zero.
rel_time | Timeout value, or Kernel::wait_for_u32_forever. |
T* try_calloc_until | ( | Kernel::Clock::time_point | abs_time | ) |
Allocate a memory block of type T, blocking, and set memory block to zero.
abs_time | Absolute timeout time, referenced to Kernel::Clock. |
T* try_get | ( | ) |
T* try_get_for | ( | Kernel::Clock::duration_u32 | rel_time | ) |
Get a mail from the queue.
rel_time | Timeout value or Kernel::wait_for_u32_forever. |