µOS++ IIIe Reference  v6.3.15
“Perfekt ist nicht gut genug”
The third edition of µOS++, a POSIX inspired open source system, written in C++.
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...
 

Types

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

Variables

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

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);
}
}

Types

◆ allocator_type

◆ index_t

Type of list index storage.

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

◆ msg_size_t

Type of message size storage.

Definition at line 88 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 116 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 75 of file os-mqueue.h.

Variable Documentation

◆ default_priority

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

Default message priority.

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

Definition at line 124 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 207 of file os-mqueue.h.

◆ max_msg_size

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

Maximum message size.

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

◆ max_priority

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

Maximum message priority.

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

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

◆ max_size

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

Maximum queue size.

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

◆ no_index

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

Index value to represent an illegal index.

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