µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
Message queues

C++ API message queues definitions. More...

Classes

class  os::rtos::message_queue::attributes
 Message queue attributes. More...
 
class  os::rtos::message_queue
 POSIX compliant message queue, using the default RTOS allocator. More...
 
class  os::rtos::message_queue_allocated< Allocator >
 Template of a POSIX compliant message queue with allocator. More...
 
class  os::rtos::message_queue_inclusive< T, N >
 Template of a POSIX compliant message queue with message type and local storage. More...
 
class  os::rtos::message_queue_typed< T, Allocator >
 Template of a POSIX compliant message queue with message type and allocator. More...
 

Typedefs

using os::rtos::message_queue::allocator_type = memory::allocator< thread::stack::allocation_element_t >
 Default RTOS allocator.
 
using os::rtos::message_queue::index_t = message_queue::size_t
 Type of list index storage.
 
using os::rtos::message_queue::msg_size_t = uint16_t
 Type of message size storage.
 
using os::rtos::message_queue::priority_t = uint8_t
 Type of message priority storage.
 
using os::rtos::message_queue::size_t = uint8_t
 Type of a queue size storage.
 

Variables

static constexpr priority_t os::rtos::message_queue::default_priority = 0
 Default message priority.
 
static const attributes os::rtos::message_queue::initializer
 Default message queue initialiser.
 
static constexpr msg_size_t os::rtos::message_queue::max_msg_size = 0xFFFF
 Maximum message size.
 
static constexpr priority_t os::rtos::message_queue::max_priority = 0xFF
 Maximum message priority.
 
static constexpr message_queue::size_t os::rtos::message_queue::max_size = 0xFF
 Maximum queue size.
 
static constexpr index_t os::rtos::message_queue::no_index = max_size
 Index value to represent an illegal index.
 

Detailed Description

C++ API message queues definitions.

Examples
typedef struct my_msg_s
{
int i;
const char* s;
} my_msg_t;
int
os_main (int argc, char* argv[])
{
my_msg_t msg_out
{ 1, "msg" };
my_msg_t msg_in;
// --------------------------------------------------------------------------
// Classic usage; message size and cast to char* must be supplied manually.
{
message_queue cq1
{ 3, sizeof(my_msg_t) };
cq1.send (&msg_out, sizeof(my_msg_t));
message_queue cq2
{ "cq2", 3, sizeof(my_msg_t) };
cq2.send (&msg_out, sizeof(my_msg_t));
}
// --------------------------------------------------------------------------
// Template usage; message size and cast are supplied automatically.
// Define a custom queue type parametrised with the
// message type.
using My_queue = message_queue_typed<my_msg_t>;
{
My_queue tq1
{ 7 };
tq1.send (&msg_out);
tq1.receive (&msg_in);
tq1.try_send (&msg_out);
tq1.try_receive (&msg_in);
tq1.timed_send (&msg_out, 1);
tq1.timed_receive (&msg_in, 1);
My_queue tq2
{ "tq2", 7 };
tq2.send (&msg_out);
tq2.receive (&msg_in);
}
// --------------------------------------------------------------------------
// Allocated template usage; message size and cast are supplied automatically.
// Define a custom queue type parametrised with the
// message type and the queue size.
using My_inclusive_queue = message_queue_inclusive<my_msg_t, 4>;
{
// The space for the queue is allocated inside the queue
// object, in this case on the stack.
My_inclusive_queue sq1;
sq1.send (&msg_out);
sq1.receive (&msg_in);
sq1.try_send (&msg_out);
sq1.try_receive (&msg_in);
sq1.timed_send (&msg_out, 1);
sq1.timed_receive (&msg_in, 1);
My_inclusive_queue sq2
{ "sq2" };
sq2.send (&msg_out);
sq2.receive (&msg_in);
}
}
int os_main(int argc, char *argv[])
Application entry point, running on the main thread context.

Typedef Documentation

◆ allocator_type

◆ index_t

Type of list index storage.

Definition at line 109 of file os-mqueue.h.

◆ msg_size_t

Type of message size storage.

Definition at line 97 of file os-mqueue.h.

◆ priority_t

Type of message priority storage.

A numeric value to hold the message priority, which controls the order in which messages are added to the queue (higher values represent higher priorities).

Definition at line 125 of file os-mqueue.h.

◆ size_t

Type of a queue size storage.

A numeric value to hold the message queue size, usually an 8-bits value, possibly a 16-bits value if longer queues are needed.

Definition at line 84 of file os-mqueue.h.

Variable Documentation

◆ default_priority

constexpr priority_t os::rtos::message_queue::default_priority = 0
staticconstexpr

Default message priority.

Use this value with send() if no special priorities are required.

Definition at line 133 of file os-mqueue.h.

◆ initializer

const message_queue::attributes os::rtos::message_queue::initializer
static

Default message queue initialiser.

This variable is used by the default constructor.

Definition at line 216 of file os-mqueue.h.

◆ max_msg_size

constexpr msg_size_t os::rtos::message_queue::max_msg_size = 0xFFFF
staticconstexpr

Maximum message size.

Definition at line 103 of file os-mqueue.h.

◆ max_priority

constexpr priority_t os::rtos::message_queue::max_priority = 0xFF
staticconstexpr

Maximum message priority.

The maximum value allowed by the type, usually used for validation.

Definition at line 142 of file os-mqueue.h.

◆ max_size

constexpr message_queue::size_t os::rtos::message_queue::max_size = 0xFF
staticconstexpr

Maximum queue size.

Definition at line 91 of file os-mqueue.h.

◆ no_index

constexpr index_t os::rtos::message_queue::no_index = max_size
staticconstexpr

Index value to represent an illegal index.

Definition at line 115 of file os-mqueue.h.