Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
Mail< T, queue_sz > Class Template Reference

The Mail class allows you to control, send, receive or wait for mail. More...

#include <Mail.h>

Inheritance diagram for Mail< T, queue_sz >:
NonCopyable< Mail< T, queue_sz > >

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 (uint32_t millisec=0)
 Allocate a memory block of type T. More...
 
T * calloc (uint32_t millisec=0)
 Allocate a memory block of type T, 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...
 

Detailed Description

template<typename T, uint32_t queue_sz>
class rtos::Mail< T, queue_sz >

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

Template Parameters
TData type of a single mail message element.
queue_szMaximum number of mail messages in queue.
Note
Memory considerations: The mail data store and control structures are part of this class - they do not (themselves) allocate memory on the heap, both for the Mbed OS and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).

Definition at line 59 of file Mail.h.

Constructor & Destructor Documentation

Mail ( )

Create and initialize Mail queue.

Note
You cannot call this function from ISR context.

Definition at line 65 of file Mail.h.

Member Function Documentation

T* alloc ( uint32_t  millisec = 0)

Allocate a memory block of type T.

Parameters
millisecNot used.
Returns
Pointer to memory block that you can fill with mail or NULL in case error.
Note
You may call this function from ISR context.

Definition at line 101 of file Mail.h.

T* calloc ( uint32_t  millisec = 0)

Allocate a memory block of type T, and set memory block to zero.

Parameters
millisecNot used.
Returns
Pointer to memory block that you can fill with mail or NULL in case error.
Note
You may call this function from ISR context.

Definition at line 114 of file Mail.h.

bool empty ( ) const

Check if the mail queue is empty.

Returns
State of queue.
Return values
trueMail queue is empty.
falseMail queue contains mail.
Note
You may call this function from ISR context.

Definition at line 75 of file Mail.h.

osStatus free ( T *  mptr)

Free a memory block from a mail.

Parameters
mptrPointer to the memory block that was obtained with Mail::get.
Returns
Status code that indicates the execution status of the function (osOK on success).
Note
You may call this function from ISR context.

Definition at line 161 of file Mail.h.

bool full ( ) const

Check if the mail queue is full.

Returns
State of queue.
Return values
trueMail queue is full.
falseMail queue is not full.
Note
You may call this function from ISR context.

Definition at line 88 of file Mail.h.

osEvent get ( uint32_t  millisec = osWaitForever)

Get a mail from the queue.

Parameters
millisecTimeout value (default: osWaitForever).
Returns
Event that contains mail information or error code.
Return values
osEventMessageMessage received.
osOKNo mail is available (and no timeout was specified).
osEventTimeoutNo mail has arrived during the given timeout period.
osErrorParameterA parameter is invalid or outside of a permitted range.
Note
You may call this function from ISR context if the millisec parameter is set to 0.

Definition at line 144 of file Mail.h.

osStatus put ( T *  mptr)

Put a mail in the queue.

Parameters
mptrMemory block previously allocated with Mail::alloc or Mail::calloc.
Returns
Status code that indicates the execution status of the function (osOK on success).
Note
You may call this function from ISR context.

Definition at line 127 of file Mail.h.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.