distortos
v0.7.0
object-oriented C++ RTOS for microcontrollers
|
RawMessageQueue class is very similar to MessageQueue, but optimized for binary serializable types (like POD types). More...
#include "distortos/RawMessageQueue.hpp"
Public Types | |
using | EntryStorage = internal::MessageQueueBase::EntryStorage |
type of uninitialized storage for Entry with link More... | |
using | EntryStorageUniquePointer = internal::MessageQueueBase::EntryStorageUniquePointer |
import EntryStorageUniquePointer type from internal::MessageQueueBase class More... | |
template<typename T > | |
using | ValueStorage = internal::MessageQueueBase::ValueStorage< T > |
using | ValueStorageUniquePointer = internal::MessageQueueBase::ValueStorageUniquePointer |
unique_ptr (with deleter) to storage for value More... | |
Public Member Functions | |
RawMessageQueue (EntryStorageUniquePointer &&entryStorageUniquePointer, ValueStorageUniquePointer &&valueStorageUniquePointer, size_t elementSize, size_t maxElements) | |
RawMessageQueue's constructor. More... | |
size_t | getCapacity () const |
size_t | getElementSize () const |
int | pop (uint8_t &priority, void *buffer, size_t size) |
Pops oldest element with highest priority from the queue. More... | |
template<typename T > | |
int | pop (uint8_t &priority, T &buffer) |
Pops oldest element with highest priority from the queue. More... | |
int | push (uint8_t priority, const void *data, size_t size) |
Pushes the element to the queue. More... | |
template<typename T > | |
int | push (const uint8_t priority, const T &data) |
Pushes the element to the queue. More... | |
int | tryPop (uint8_t &priority, void *buffer, size_t size) |
Tries to pop the oldest element with highest priority from the queue. More... | |
template<typename T > | |
int | tryPop (uint8_t &priority, T &buffer) |
Tries to pop the oldest element with highest priority from the queue. More... | |
int | tryPopFor (TickClock::duration duration, uint8_t &priority, void *buffer, size_t size) |
Tries to pop the oldest element with highest priority from the queue for a given duration of time. More... | |
template<typename Rep , typename Period > | |
int | tryPopFor (const std::chrono::duration< Rep, Period > duration, uint8_t &priority, void *const buffer, const size_t size) |
Tries to pop the oldest element with highest priority from the queue for a given duration of time. More... | |
template<typename Rep , typename Period , typename T > | |
int | tryPopFor (const std::chrono::duration< Rep, Period > duration, uint8_t &priority, T &buffer) |
Tries to pop the oldest element with highest priority from the queue for a given duration of time. More... | |
int | tryPopUntil (TickClock::time_point timePoint, uint8_t &priority, void *buffer, size_t size) |
Tries to pop the oldest element with highest priority from the queue until a given time point. More... | |
template<typename Duration > | |
int | tryPopUntil (const std::chrono::time_point< TickClock, Duration > timePoint, uint8_t &priority, void *const buffer, const size_t size) |
Tries to pop the oldest element with highest priority from the queue until a given time point. More... | |
template<typename Duration , typename T > | |
int | tryPopUntil (const std::chrono::time_point< TickClock, Duration > timePoint, uint8_t &priority, T &buffer) |
Tries to pop the oldest element with highest priority from the queue until a given time point. More... | |
int | tryPush (uint8_t priority, const void *data, size_t size) |
Tries to push the element to the queue. More... | |
template<typename T > | |
int | tryPush (const uint8_t priority, const T &data) |
Tries to push the element to the queue. More... | |
int | tryPushFor (TickClock::duration duration, uint8_t priority, const void *data, size_t size) |
Tries to push the element to the queue for a given duration of time. More... | |
template<typename Rep , typename Period > | |
int | tryPushFor (const std::chrono::duration< Rep, Period > duration, const uint8_t priority, const void *const data, const size_t size) |
Tries to push the element to the queue for a given duration of time. More... | |
template<typename Rep , typename Period , typename T > | |
int | tryPushFor (const std::chrono::duration< Rep, Period > duration, const uint8_t priority, const T &data) |
Tries to push the element to the queue for a given duration of time. More... | |
int | tryPushUntil (TickClock::time_point timePoint, uint8_t priority, const void *data, size_t size) |
Tries to push the element to the queue until a given time point. More... | |
template<typename Duration > | |
int | tryPushUntil (const std::chrono::time_point< TickClock, Duration > timePoint, const uint8_t priority, const void *const data, const size_t size) |
Tries to push the element to the queue until a given time point. More... | |
template<typename Duration , typename T > | |
int | tryPushUntil (const std::chrono::time_point< TickClock, Duration > timePoint, const uint8_t priority, const T &data) |
Tries to push the element to the queue until a given time point. More... | |
Private Member Functions | |
int | popInternal (const internal::SemaphoreFunctor &waitSemaphoreFunctor, uint8_t &priority, void *buffer, size_t size) |
Pops oldest element with highest priority from the queue. More... | |
int | pushInternal (const internal::SemaphoreFunctor &waitSemaphoreFunctor, uint8_t priority, const void *data, size_t size) |
Pushes the element to the queue. More... | |
Private Attributes | |
internal::MessageQueueBase | messageQueueBase_ |
contained internal::MessageQueueBase object which implements base functionality More... | |
const size_t | elementSize_ |
size of single queue element, bytes More... | |
RawMessageQueue class is very similar to MessageQueue, but optimized for binary serializable types (like POD types).
Type T can be used with both RawMessageQueue and MessageQueue only when std::is_trivially_copyable<T>::value == true, otherwise only MessageQueue use is safe, while using RawMessageQueue results in undefined behavior.
Similar to POSIX mqd_t - http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/mqueue.h.html
type of uninitialized storage for Entry with link
using distortos::RawMessageQueue::EntryStorageUniquePointer = internal::MessageQueueBase::EntryStorageUniquePointer |
import EntryStorageUniquePointer type from internal::MessageQueueBase class
using distortos::RawMessageQueue::ValueStorage = internal::MessageQueueBase::ValueStorage<T> |
type of uninitialized storage for value
T | is the type of data in queue |
using distortos::RawMessageQueue::ValueStorageUniquePointer = internal::MessageQueueBase::ValueStorageUniquePointer |
unique_ptr (with deleter) to storage for value
distortos::RawMessageQueue::RawMessageQueue | ( | EntryStorageUniquePointer && | entryStorageUniquePointer, |
ValueStorageUniquePointer && | valueStorageUniquePointer, | ||
size_t | elementSize, | ||
size_t | maxElements | ||
) |
RawMessageQueue's constructor.
[in] | entryStorageUniquePointer | is a rvalue reference to EntryStorageUniquePointer with storage for queue entries (sufficiently large for maxElements EntryStorage objects) and appropriate deleter |
[in] | valueStorageUniquePointer | is a rvalue reference to ValueStorageUniquePointer with storage for queue elements (sufficiently large for maxElements, each elementSize bytes long) and appropriate deleter |
[in] | elementSize | is the size of single queue element, bytes |
[in] | maxElements | is the number of elements in entryStorage array and valueStorage memory block |
|
inline |
|
inline |
int distortos::RawMessageQueue::pop | ( | uint8_t & | priority, |
void * | buffer, | ||
size_t | size | ||
) |
Pops oldest element with highest priority from the queue.
Similar to mq_receive() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html#
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a pointer to buffer for popped element |
[in] | size | is the size of buffer, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Pops oldest element with highest priority from the queue.
Similar to mq_receive() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html#
T | is the type of data popped from the queue |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a reference to object that will be used to return popped value |
|
private |
Pops oldest element with highest priority from the queue.
Internal version - builds the Functor object.
[in] | waitSemaphoreFunctor | is a reference to SemaphoreFunctor which will be executed with popSemaphore_ |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a pointer to buffer for popped element |
[in] | size | is the size of buffer, bytes - must be equal to the elementSize attribute of RawMessageQueue |
int distortos::RawMessageQueue::push | ( | uint8_t | priority, |
const void * | data, | ||
size_t | size | ||
) |
Pushes the element to the queue.
Similar to mq_send() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html#
[in] | priority | is the priority of new element |
[in] | data | is a pointer to data that will be pushed to RawMessageQueue |
[in] | size | is the size of data, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Pushes the element to the queue.
Similar to mq_send() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html#
T | is the type of data pushed to the queue |
[in] | priority | is the priority of new element |
[in] | data | is a reference to data that will be pushed to RawMessageQueue |
|
private |
Pushes the element to the queue.
Internal version - builds the Functor object.
[in] | waitSemaphoreFunctor | is a reference to SemaphoreFunctor which will be executed with pushSemaphore_ |
[in] | priority | is the priority of new element |
[in] | data | is a pointer to data that will be pushed to RawMessageQueue |
[in] | size | is the size of data, bytes - must be equal to the elementSize attribute of RawMessageQueue |
int distortos::RawMessageQueue::tryPop | ( | uint8_t & | priority, |
void * | buffer, | ||
size_t | size | ||
) |
Tries to pop the oldest element with highest priority from the queue.
Similar to mq_receive() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html#
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a pointer to buffer for popped element |
[in] | size | is the size of buffer, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to pop the oldest element with highest priority from the queue.
Similar to mq_receive() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html#
T | is the type of data popped from the queue |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a reference to object that will be used to return popped value |
int distortos::RawMessageQueue::tryPopFor | ( | TickClock::duration | duration, |
uint8_t & | priority, | ||
void * | buffer, | ||
size_t | size | ||
) |
Tries to pop the oldest element with highest priority from the queue for a given duration of time.
Similar to mq_timedreceive() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html#
[in] | duration | is the duration after which the call will be terminated without popping the element |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a pointer to buffer for popped element |
[in] | size | is the size of buffer, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to pop the oldest element with highest priority from the queue for a given duration of time.
Template variant of tryPopFor(TickClock::duration, uint8_t&, void*, size_t).
Rep | is type of tick counter |
Period | is std::ratio type representing the tick period of the clock, seconds |
[in] | duration | is the duration after which the call will be terminated without popping the element |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a pointer to buffer for popped element |
[in] | size | is the size of buffer, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to pop the oldest element with highest priority from the queue for a given duration of time.
Similar to mq_timedreceive() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html#
Rep | is type of tick counter |
Period | is std::ratio type representing the tick period of the clock, seconds |
T | is the type of data popped from the queue |
[in] | duration | is the duration after which the call will be terminated without popping the element |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a reference to object that will be used to return popped value |
int distortos::RawMessageQueue::tryPopUntil | ( | TickClock::time_point | timePoint, |
uint8_t & | priority, | ||
void * | buffer, | ||
size_t | size | ||
) |
Tries to pop the oldest element with highest priority from the queue until a given time point.
Similar to mq_timedreceive() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html#
[in] | timePoint | is the time point at which the call will be terminated without popping the element |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a pointer to buffer for popped element |
[in] | size | is the size of buffer, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to pop the oldest element with highest priority from the queue until a given time point.
Template variant of tryPopUntil(TickClock::time_point, uint8_t&, void*, size_t).
Duration | is a std::chrono::duration type used to measure duration |
[in] | timePoint | is the time point at which the call will be terminated without popping the element |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a pointer to buffer for popped element |
[in] | size | is the size of buffer, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to pop the oldest element with highest priority from the queue until a given time point.
Similar to mq_timedreceive() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html#
Duration | is a std::chrono::duration type used to measure duration |
T | is the type of data popped from the queue |
[in] | timePoint | is the time point at which the call will be terminated without popping the element |
[out] | priority | is a reference to variable that will be used to return priority of popped value |
[out] | buffer | is a reference to object that will be used to return popped value |
int distortos::RawMessageQueue::tryPush | ( | uint8_t | priority, |
const void * | data, | ||
size_t | size | ||
) |
Tries to push the element to the queue.
Similar to mq_send() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html#
[in] | priority | is the priority of new element |
[in] | data | is a pointer to data that will be pushed to RawMessageQueue |
[in] | size | is the size of data, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to push the element to the queue.
Similar to mq_send() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html#
T | is the type of data pushed to the queue |
[in] | priority | is the priority of new element |
[in] | data | is a reference to data that will be pushed to RawMessageQueue |
int distortos::RawMessageQueue::tryPushFor | ( | TickClock::duration | duration, |
uint8_t | priority, | ||
const void * | data, | ||
size_t | size | ||
) |
Tries to push the element to the queue for a given duration of time.
Similar to mq_timedsend() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html#
[in] | duration | is the duration after which the wait will be terminated without pushing the element |
[in] | priority | is the priority of new element |
[in] | data | is a pointer to data that will be pushed to RawMessageQueue |
[in] | size | is the size of data, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to push the element to the queue for a given duration of time.
Template variant of tryPushFor(TickClock::duration, uint8_t, const void*, size_t).
Rep | is type of tick counter |
Period | is std::ratio type representing the tick period of the clock, seconds |
[in] | duration | is the duration after which the wait will be terminated without pushing the element |
[in] | priority | is the priority of new element |
[in] | data | is a pointer to data that will be pushed to RawMessageQueue |
[in] | size | is the size of data, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to push the element to the queue for a given duration of time.
Similar to mq_timedsend() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html#
Rep | is type of tick counter |
Period | is std::ratio type representing the tick period of the clock, seconds |
T | is the type of data pushed to the queue |
[in] | duration | is the duration after which the wait will be terminated without pushing the element |
[in] | priority | is the priority of new element |
[in] | data | is a reference to data that will be pushed to RawMessageQueue |
int distortos::RawMessageQueue::tryPushUntil | ( | TickClock::time_point | timePoint, |
uint8_t | priority, | ||
const void * | data, | ||
size_t | size | ||
) |
Tries to push the element to the queue until a given time point.
Similar to mq_timedsend() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html#
[in] | timePoint | is the time point at which the call will be terminated without pushing the element |
[in] | priority | is the priority of new element |
[in] | data | is a pointer to data that will be pushed to RawMessageQueue |
[in] | size | is the size of data, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to push the element to the queue until a given time point.
Template variant of tryPushUntil(TickClock::time_point, uint8_t, const void*, size_t).
Duration | is a std::chrono::duration type used to measure duration |
[in] | timePoint | is the time point at which the call will be terminated without pushing the element |
[in] | priority | is the priority of new element |
[in] | data | is a pointer to data that will be pushed to RawMessageQueue |
[in] | size | is the size of data, bytes - must be equal to the elementSize attribute of RawMessageQueue |
|
inline |
Tries to push the element to the queue until a given time point.
Similar to mq_timedsend() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html#
Duration | is a std::chrono::duration type used to measure duration |
T | is the type of data pushed to the queue |
[in] | timePoint | is the time point at which the call will be terminated without pushing the element |
[in] | priority | is the priority of new element |
[in] | data | is a reference to data that will be pushed to RawMessageQueue |
|
private |
size of single queue element, bytes
|
private |
contained internal::MessageQueueBase object which implements base functionality