distortos
v0.7.0
object-oriented C++ RTOS for microcontrollers
|
FifoQueue class is a simple FIFO queue for thread-thread, thread-interrupt or interrupt-interrupt communication. It supports multiple readers and multiple writers. It is implemented as a wrapper for internal::FifoQueueBase. More...
#include "distortos/FifoQueue.hpp"
Public Types | |
using | Storage = typename std::aligned_storage< sizeof(T), alignof(T)>::type |
type of uninitialized storage for data More... | |
using | StorageUniquePointer = std::unique_ptr< Storage[], internal::FifoQueueBase::StorageUniquePointer::deleter_type > |
unique_ptr (with deleter) to Storage[] More... | |
using | ValueType = T |
type of data in queue More... | |
Public Member Functions | |
FifoQueue (StorageUniquePointer &&storageUniquePointer, const size_t maxElements) | |
FifoQueue's constructor. More... | |
~FifoQueue () | |
FifoQueue's destructor. More... | |
template<typename... Args> | |
int | emplace (Args &&... args) |
Emplaces the element in the queue. More... | |
size_t | getCapacity () const |
int | pop (T &value) |
Pops the oldest (first) element from the queue. More... | |
int | push (const T &value) |
Pushes the element to the queue. More... | |
int | push (T &&value) |
Pushes the element to the queue. More... | |
template<typename... Args> | |
int | tryEmplace (Args &&... args) |
Tries to emplace the element in the queue. More... | |
template<typename... Args> | |
int | tryEmplaceFor (const TickClock::duration duration, Args &&... args) |
Tries to emplace the element in the queue for a given duration of time. More... | |
template<typename Rep , typename Period , typename... Args> | |
int | tryEmplaceFor (const std::chrono::duration< Rep, Period > duration, Args &&... args) |
Tries to emplace the element in the queue for a given duration of time. More... | |
template<typename... Args> | |
int | tryEmplaceUntil (const TickClock::time_point timePoint, Args &&... args) |
Tries to emplace the element in the queue until a given time point. More... | |
template<typename Duration , typename... Args> | |
int | tryEmplaceUntil (const std::chrono::time_point< TickClock, Duration > timePoint, Args &&... args) |
Tries to emplace the element in the queue until a given time point. More... | |
int | tryPop (T &value) |
Tries to pop the oldest (first) element from the queue. More... | |
int | tryPopFor (const TickClock::duration duration, T &value) |
Tries to pop the oldest (first) element from the queue for a given duration of time. More... | |
template<typename Rep , typename Period > | |
int | tryPopFor (const std::chrono::duration< Rep, Period > duration, T &value) |
Tries to pop the oldest (first) element from the queue for a given duration of time. More... | |
int | tryPopUntil (const TickClock::time_point timePoint, T &value) |
Tries to pop the oldest (first) element from the queue until a given time point. More... | |
template<typename Duration > | |
int | tryPopUntil (const std::chrono::time_point< TickClock, Duration > timePoint, T &value) |
Tries to pop the oldest (first) element from the queue until a given time point. More... | |
int | tryPush (const T &value) |
Tries to push the element to the queue. More... | |
int | tryPush (T &&value) |
Tries to push the element to the queue. More... | |
int | tryPushFor (const TickClock::duration duration, const T &value) |
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 T &value) |
Tries to push the element to the queue for a given duration of time. More... | |
int | tryPushFor (const TickClock::duration duration, T &&value) |
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, T &&value) |
Tries to push the element to the queue for a given duration of time. More... | |
int | tryPushUntil (const TickClock::time_point timePoint, const T &value) |
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 T &value) |
Tries to push the element to the queue until a given time point. More... | |
int | tryPushUntil (const TickClock::time_point timePoint, T &&value) |
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, T &&value) |
Tries to push the element to the queue until a given time point. More... | |
Private Member Functions | |
template<typename... Args> | |
int | emplaceInternal (const internal::SemaphoreFunctor &waitSemaphoreFunctor, Args &&... args) |
Emplaces the element in the queue. More... | |
int | popInternal (const internal::SemaphoreFunctor &waitSemaphoreFunctor, T &value) |
Pops the oldest (first) element from the queue. More... | |
int | pushInternal (const internal::SemaphoreFunctor &waitSemaphoreFunctor, const T &value) |
Pushes the element to the queue. More... | |
int | pushInternal (const internal::SemaphoreFunctor &waitSemaphoreFunctor, T &&value) |
Pushes the element to the queue. More... | |
Private Attributes | |
internal::FifoQueueBase | fifoQueueBase_ |
contained internal::FifoQueueBase object which implements whole functionality More... | |
FifoQueue class is a simple FIFO queue for thread-thread, thread-interrupt or interrupt-interrupt communication. It supports multiple readers and multiple writers. It is implemented as a wrapper for internal::FifoQueueBase.
T | is the type of data in queue |
using distortos::FifoQueue< T >::Storage = typename std::aligned_storage<sizeof(T), alignof(T)>::type |
type of uninitialized storage for data
using distortos::FifoQueue< T >::StorageUniquePointer = std::unique_ptr<Storage[], internal::FifoQueueBase::StorageUniquePointer::deleter_type> |
unique_ptr (with deleter) to Storage[]
using distortos::FifoQueue< T >::ValueType = T |
type of data in queue
|
inline |
FifoQueue's constructor.
[in] | storageUniquePointer | is a rvalue reference to StorageUniquePointer with storage for queue elements (sufficiently large for maxElements, each sizeof(T) bytes long) and appropriate deleter |
[in] | maxElements | is the number of elements in storage array |
distortos::FifoQueue< T >::~FifoQueue | ( | ) |
FifoQueue's destructor.
Pops all remaining elements from the queue.
|
inline |
Emplaces the element in the queue.
Args | are types of arguments for constructor of T |
[in] | args | are arguments for constructor of T |
|
private |
Emplaces the element in the queue.
Internal version - builds the Functor object.
Args | are types of arguments for constructor of T |
[in] | waitSemaphoreFunctor | is a reference to SemaphoreFunctor which will be executed with pushSemaphore_ |
[in] | args | are arguments for constructor of T |
|
inline |
|
inline |
Pops the oldest (first) element from the queue.
[out] | value | is a reference to object that will be used to return popped value, its contents are swapped with the value in the queue's storage and destructed when no longer needed |
|
private |
Pops the oldest (first) element from the queue.
Internal version - builds the Functor object.
[in] | waitSemaphoreFunctor | is a reference to SemaphoreFunctor which will be executed with popSemaphore_ |
[out] | value | is a reference to object that will be used to return popped value, its contents are swapped with the value in the queue's storage and destructed when no longer needed |
|
inline |
Pushes the element to the queue.
[in] | value | is a reference to object that will be pushed, value in queue's storage is copy-constructed |
|
inline |
Pushes the element to the queue.
[in] | value | is a rvalue reference to object that will be pushed, value in queue's storage is move-constructed |
|
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] | value | is a reference to object that will be pushed, value in queue's storage is copy-constructed |
|
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] | value | is a rvalue reference to object that will be pushed, value in queue's storage is move-constructed |
|
inline |
Tries to emplace the element in the queue.
Args | are types of arguments for constructor of T |
[in] | args | are arguments for constructor of T |
|
inline |
Tries to emplace the element in the queue for a given duration of time.
Args | are types of arguments for constructor of T |
[in] | duration | is the duration after which the wait will be terminated without emplacing the element |
[in] | args | are arguments for constructor of T |
|
inline |
Tries to emplace the element in the queue for a given duration of time.
Template variant of FifoQueue::tryEmplaceFor(TickClock::duration, Args&&...).
Rep | is type of tick counter |
Period | is std::ratio type representing the tick period of the clock, seconds |
Args | are types of arguments for constructor of T |
[in] | duration | is the duration after which the wait will be terminated without emplacing the element |
[in] | args | are arguments for constructor of T |
|
inline |
Tries to emplace the element in the queue until a given time point.
Args | are types of arguments for constructor of T |
[in] | timePoint | is the time point at which the call will be terminated without emplacing the element |
[in] | args | are arguments for constructor of T |
|
inline |
Tries to emplace the element in the queue until a given time point.
Template variant of FifoQueue::tryEmplaceUntil(TickClock::time_point, Args&&...).
Duration | is a std::chrono::duration type used to measure duration |
Args | are types of arguments for constructor of T |
[in] | timePoint | is the time point at which the call will be terminated without emplacing the element |
[in] | args | are arguments for constructor of T |
|
inline |
Tries to pop the oldest (first) element from the queue.
[out] | value | is a reference to object that will be used to return popped value, its contents are swapped with the value in the queue's storage and destructed when no longer needed |
|
inline |
Tries to pop the oldest (first) element from the queue for a given duration of time.
[in] | duration | is the duration after which the call will be terminated without popping the element |
[out] | value | is a reference to object that will be used to return popped value, its contents are swapped with the value in the queue's storage and destructed when no longer needed |
|
inline |
Tries to pop the oldest (first) element from the queue for a given duration of time.
Template variant of tryPopFor(TickClock::duration, 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] | value | is a reference to object that will be used to return popped value, its contents are swapped with the value in the queue's storage and destructed when no longer needed |
|
inline |
Tries to pop the oldest (first) element from the queue until a given time point.
[in] | timePoint | is the time point at which the call will be terminated without popping the element |
[out] | value | is a reference to object that will be used to return popped value, its contents are swapped with the value in the queue's storage and destructed when no longer needed |
|
inline |
Tries to pop the oldest (first) element from the queue until a given time point.
Template variant of tryPopUntil(TickClock::time_point, 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] | value | is a reference to object that will be used to return popped value, its contents are swapped with the value in the queue's storage and destructed when no longer needed |
|
inline |
Tries to push the element to the queue.
[in] | value | is a reference to object that will be pushed, value in queue's storage is copy-constructed |
|
inline |
Tries to push the element to the queue.
[in] | value | is a rvalue reference to object that will be pushed, value in queue's storage is move-constructed |
|
inline |
Tries to push the element to the queue for a given duration of time.
[in] | duration | is the duration after which the wait will be terminated without pushing the element |
[in] | value | is a reference to object that will be pushed, value in queue's storage is copy-constructed |
|
inline |
Tries to push the element to the queue for a given duration of time.
Template variant of tryPushFor(TickClock::duration, const 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] | value | is a reference to object that will be pushed, value in queue's storage is copy-constructed |
|
inline |
Tries to push the element to the queue for a given duration of time.
[in] | duration | is the duration after which the call will be terminated without pushing the element |
[in] | value | is a rvalue reference to object that will be pushed, value in queue's storage is move-constructed |
|
inline |
Tries to push the element to the queue for a given duration of time.
Template variant of tryPushFor(TickClock::duration, 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 pushing the element |
[in] | value | is a rvalue reference to object that will be pushed, value in queue's storage is move-constructed |
|
inline |
Tries to push the element to the queue until a given time point.
[in] | timePoint | is the time point at which the call will be terminated without pushing the element |
[in] | value | is a reference to object that will be pushed, value in queue's storage is copy-constructed |
|
inline |
Tries to push the element to the queue until a given time point.
Template variant of tryPushUntil(TickClock::time_point, const 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] | value | is a reference to object that will be pushed, value in queue's storage is copy-constructed |
|
inline |
Tries to push the element to the queue until a given time point.
[in] | timePoint | is the time point at which the call will be terminated without pushing the element |
[in] | value | is a rvalue reference to object that will be pushed, value in queue's storage is move-constructed |
|
inline |
Tries to push the element to the queue until a given time point.
Template variant of tryPushUntil(TickClock::time_point, 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] | value | is a rvalue reference to object that will be pushed, value in queue's storage is move-constructed |
|
private |
contained internal::FifoQueueBase object which implements whole functionality