Gleb Klochkov / Mbed OS Climatcontroll_Main

Dependencies:   esp8266-driver

Embed: (wiki syntax)

« Back to documentation index

Mail< T, queue_sz > Class Template Reference

Mail< T, queue_sz > Class Template Reference
[Mail class]

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

#include <Mail.h>

Inherits NonCopyable< Mail< T, queue_sz > >.

Public Member Functions

 Mail ()
 Create and Initialize Mail queue.
bool empty () const
 Check if the mail queue is empty.
bool full () const
 Check if the mail queue is full.
T * alloc (uint32_t millisec=0)
 Allocate a memory block of type T.
T * calloc (uint32_t millisec=0)
 Allocate a memory block of type T and set memory block to zero.
osStatus put (T *mptr)
 Put a mail in the queue.
osEvent get (uint32_t millisec=osWaitForever)
 Get a mail from a queue.
osStatus free (T *mptr)
 Free a memory block from a mail.

Private Member Functions

 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.

Detailed Description

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

The Mail class allow to control, send, receive, or wait for mail.

A mail is a memory block that is send to a thread or interrupt service routine.

Template Parameters:
Tdata type of a single message element.
queue_szmaximum number of messages in queue.
Note:
Memory considerations: The mail data store and control structures will be created on current thread's stack, both for the mbed OS and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).

Definition at line 56 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 62 of file Mail.h.


Member Function Documentation

T* alloc ( uint32_t  millisec = 0 )

Allocate a memory block of type T.

Parameters:
millisectimeout value or 0 in case of no time-out. (default: 0).
Returns:
pointer to memory block that can be filled with mail or NULL in case error.
Note:
You may call this function from ISR context if the millisec parameter is set to 0.

Definition at line 90 of file Mail.h.

T* calloc ( uint32_t  millisec = 0 )

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

Parameters:
millisectimeout value or 0 in case of no time-out. (default: 0).
Returns:
pointer to memory block that can be filled with mail or NULL in case error.
Note:
You may call this function from ISR context if the millisec parameter is set to 0.

Definition at line 100 of file Mail.h.

bool empty (  ) const

Check if the mail queue is empty.

Returns:
True if the mail queue is empty, false if not
Note:
You may call this function from ISR context.

Definition at line 70 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.
Note:
You may call this function from ISR context.

Definition at line 134 of file Mail.h.

bool full (  ) const

Check if the mail queue is full.

Returns:
True if the mail queue is full, false if not
Note:
You may call this function from ISR context.

Definition at line 80 of file Mail.h.

osEvent get ( uint32_t  millisec = osWaitForever )

Get a mail from a queue.

Parameters:
millisectimeout value or 0 in case of no time-out. (default: osWaitForever).
Returns:
event that contains mail information or error code.
Note:
You may call this function from ISR context if the millisec parameter is set to 0.

Definition at line 120 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.
Note:
You may call this function from ISR context.

Definition at line 110 of file Mail.h.