C

MessageQueue Class

template <typename MessageType, std::size_t queueCapacity> class Qul::Platform::MessageQueue

A convenience class used to interface with the queue implementation. More...

Header: #include <platform/messagequeue.h>
Since: Qt Quick Ultralite (Platform) 1.9

Public Functions

MessageQueue()
~MessageQueue()
uint32_t capacity() const
void clearOverrun()
bool discardSupported() const
Qul::Platform::MessageQueueStatus enqueueOrDiscard(const MessageType *message)
Qul::Platform::MessageQueueStatus enqueueOrDiscardFromInterrupt(const MessageType *message)
Qul::Platform::MessageQueueStatus enqueueOrOverwrite(const MessageType *message)
Qul::Platform::MessageQueueStatus enqueueOrOverwriteFromInterrupt(const MessageType *message)
bool isEmpty() const
bool isEmptyFromInterrupt() const
bool isOverrun() const
bool overwriteSupported() const
Qul::Platform::MessageQueueStatus receive(MessageType *message, int32_t timeout = 0)
Qul::Platform::MessageQueueStatus receiveFromInterrupt(MessageType *message, int32_t timeout = 0)

Detailed Description

This template class simplifies the queue's usage by automating tasks, such as queue creation, deletion, and calculation of the message size. Most of the provided functions call their Qul::Platform::MessageQueueInterface counterpart.

See also Qul::Platform::MessageQueueInterface and Qul::EventQueue.

Member Function Documentation

[since Qt Quick Ultralite (Platform) 1.9] MessageQueue::MessageQueue()

Constructs MessageQueue and requests a Qul::Platform::MessageQueueInterface implementation for the specified capacity. It uses MessageType's size as the messageSize.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also ~MessageQueue() and Qul::Platform::requestQueue().

[since Qt Quick Ultralite (Platform) 1.9] MessageQueue::~MessageQueue()

Destructs the MessageQueue instance.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueue().

[since Qt Quick Ultralite (Platform) 1.9] uint32_t MessageQueue::capacity() const

Returns the maximum number of items the queue can hold.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::capacity().

[since Qt Quick Ultralite (Platform) 1.9] void MessageQueue::clearOverrun()

Clears implementation's overrun flag.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::clearOverrun() and isOverrun().

[since Qt Quick Ultralite (Platform) 1.9] bool MessageQueue::discardSupported() const

Returns true if the implementation supports discarding.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::discardSupported(), overwriteSupported(), enqueueOrDiscard(), and enqueueOrDiscardFromInterrupt().

[since Qt Quick Ultralite (Platform) 1.9] Qul::Platform::MessageQueueStatus MessageQueue::enqueueOrDiscard(const MessageType *message)

Adds message to the queue or discards it if the queue is full. Returns MessageQueueStatus indicating the result of the function call.

Note: message must contain intrinsic types only as the default implementations in Qt Quick Ultralite do not handle non-intrinsic types. If you want to use non-intrinsic types, provide your own MessageQueueInterface implementation. See Implementing custom queues for more information.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::enqueueOrDiscard(), enqueueOrDiscardFromInterrupt(), discardSupported(), receive(), receiveFromInterrupt(), and enqueueOrOverwrite().

[since Qt Quick Ultralite (Platform) 1.9] Qul::Platform::MessageQueueStatus MessageQueue::enqueueOrDiscardFromInterrupt(const MessageType *message)

Interrupt-safe version of enqueueOrDiscard().

Note: message must contain intrinsic types only as the default implementations in Qt Quick Ultralite do not handle non-intrinsic types. If you want to use non-intrinsic types, provide your own MessageQueueInterface implementation. See Implementing custom queues for more information.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::enqueueOrDiscardFromInterrupt(), enqueueOrDiscard(), discardSupported(), receive(), receiveFromInterrupt(), and enqueueOrOverwriteFromInterrupt().

[since Qt Quick Ultralite (Platform) 1.9] Qul::Platform::MessageQueueStatus MessageQueue::enqueueOrOverwrite(const MessageType *message)

Adds message or overwrites the oldest item in the queue if the queue is full. Returns MessageQueueStatus indicating the result of the function call.

Note: message must contain intrinsic types only as the default implementations in Qt Quick Ultralite do not handle non-intrinsic types. If you want to use non-intrinsic types, provide your own MessageQueueInterface implementation. See Implementing custom queues for more information.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::enqueueOrOverwrite(), enqueueOrOverwriteFromInterrupt(), overwriteSupported(), receive(), receiveFromInterrupt(), and enqueueOrDiscard().

[since Qt Quick Ultralite (Platform) 1.9] Qul::Platform::MessageQueueStatus MessageQueue::enqueueOrOverwriteFromInterrupt(const MessageType *message)

Interrupt-safe version of enqueueOrOverwrite().

Note: message must contain intrinsic types only as the default implementations in Qt Quick Ultralite do not handle non-intrinsic types. If you want to use non-intrinsic types, provide your own MessageQueueInterface implementation. See Implementing custom queues for more information.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::enqueueOrOverwriteFromInterrupt(), enqueueOrOverwrite(), overwriteSupported(), receive(), receiveFromInterrupt(), and enqueueOrDiscardFromInterrupt().

[since Qt Quick Ultralite (Platform) 1.9] bool MessageQueue::isEmpty() const

Returns true if the queue is empty, or false otherwise.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::isEmpty() and isEmptyFromInterrupt().

[since Qt Quick Ultralite (Platform) 1.9] bool MessageQueue::isEmptyFromInterrupt() const

Returns true if the queue is empty, or false otherwise. It is similar to isEmpty() but interrupt-safe.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::isEmptyFromInterrupt() and isEmpty().

[since Qt Quick Ultralite (Platform) 1.9] bool MessageQueue::isOverrun() const

Returns true if the implementation's queue is overrun by items that are either discarded or overwritten.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::isOverrun() and clearOverrun().

[since Qt Quick Ultralite (Platform) 1.9] bool MessageQueue::overwriteSupported() const

Returns true if the implementation supports overwriting.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::overwriteSupported(), discardSupported(), enqueueOrOverwrite(), and enqueueOrOverwriteFromInterrupt().

[since Qt Quick Ultralite (Platform) 1.9] Qul::Platform::MessageQueueStatus MessageQueue::receive(MessageType *message, int32_t timeout = 0)

Returns the first message from the queue. If timeout is specified, the function blocks for timeout milliseconds. A zero timeout value means that the function does not block at all, and a negative value means that the function waits infinitely.

message must be a pointer to a location that can hold the entire MessageType. The message from the queue will be written using memcpy (or an equivalent function) to the location pointed by message.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::receive(), receiveFromInterrupt(), enqueueOrDiscard(), enqueueOrDiscardFromInterrupt(), enqueueOrOverwrite(), and enqueueOrOverwriteFromInterrupt().

[since Qt Quick Ultralite (Platform) 1.9] Qul::Platform::MessageQueueStatus MessageQueue::receiveFromInterrupt(MessageType *message, int32_t timeout = 0)

Interrupt-safe version of receive().

message must be a pointer to a location that can hold the entire MessageType. The message from the queue will be written using memcpy (or an equivalent function) to the location pointed by message.

Note: In general, functions called from interrupts should not block at all. Depending on the implementation, the timeout argument might be ignored even if it is a non-zero value.

This function was introduced in Qt Quick Ultralite (Platform) 1.9.

See also MessageQueueInterface::receiveFromInterrupt(), receive(), enqueueOrDiscard(), enqueueOrDiscardFromInterrupt(), enqueueOrOverwrite(), and enqueueOrOverwriteFromInterrupt().

Available under certain Qt licenses.
Find out more.