Orocos Real-Time Toolkit
2.9.0
|
Create an atomic, non-blocking single ended queue (FIFO) for storing a pointer to T. More...
#include <rtt/internal/AtomicMWMRQueue.hpp>
Public Types | |
typedef AtomicQueue< T >::size_type | size_type |
Public Member Functions | |
AtomicMWMRQueue (unsigned int size) | |
Create an AtomicQueue with queue size size. More... | |
~AtomicMWMRQueue () | |
bool | isFull () const |
Inspect if the Queue is full. More... | |
bool | isEmpty () const |
Inspect if the Queue is empty. More... | |
size_type | capacity () const |
Return the maximum number of items this queue can contain. More... | |
size_type | size () const |
Return the exact number of elements in the queue. More... | |
bool | enqueue (const T &value) |
Enqueue an item. More... | |
bool | dequeue (T &result) |
Dequeue an item. More... | |
const T | front () const |
Return the next to be read value. More... | |
void | clear () |
Clear all contents of the Queue and thus make it empty. More... | |
Create an atomic, non-blocking single ended queue (FIFO) for storing a pointer to T.
It is a Many Readers, Many Writers implementation based on the atomic Compare And Swap instruction. Any number of threads may access the queue concurrently.
This queue tries to obey strict ordering, but under high contention of reads interfering writes, one or more elements may be dequeued out of order. For this reason, size() is expensive to accurately calculate the size.
Due to the same limitations, it is possible that the full capacity of the queue is not used (simulations show seldomly an off by one element if capacity==10) and that isFull() returns true, while size() < capacity().
T | The pointer type to be stored in the Queue. Example : AtomicQueue< A* > is a queue of pointers to A. |
Definition at line 71 of file AtomicMWMRQueue.hpp.
typedef AtomicQueue<T>::size_type RTT::internal::AtomicMWMRQueue< T >::size_type |
Definition at line 185 of file AtomicMWMRQueue.hpp.
|
inline |
Create an AtomicQueue with queue size size.
size | The size of the queue, should be 1 or greater. |
Definition at line 191 of file AtomicMWMRQueue.hpp.
References RTT::internal::AtomicMWMRQueue< T >::clear().
|
inline |
Definition at line 198 of file AtomicMWMRQueue.hpp.
|
inlinevirtual |
Return the maximum number of items this queue can contain.
Implements RTT::internal::AtomicQueue< T >.
Definition at line 232 of file AtomicMWMRQueue.hpp.
|
inlinevirtual |
Clear all contents of the Queue and thus make it empty.
Implements RTT::internal::AtomicQueue< T >.
Definition at line 305 of file AtomicMWMRQueue.hpp.
Referenced by RTT::internal::AtomicMWMRQueue< T >::AtomicMWMRQueue().
|
inlinevirtual |
Dequeue an item.
value | The value dequeued. |
Implements RTT::internal::AtomicQueue< T >.
Definition at line 279 of file AtomicMWMRQueue.hpp.
References RTT::os::CAS().
|
inlinevirtual |
Enqueue an item.
value | The value to enqueue, not zero. |
Implements RTT::internal::AtomicQueue< T >.
Definition at line 259 of file AtomicMWMRQueue.hpp.
References RTT::os::CAS().
|
inlinevirtual |
Return the next to be read value.
Implements RTT::internal::AtomicQueue< T >.
Definition at line 297 of file AtomicMWMRQueue.hpp.
|
inlinevirtual |
Inspect if the Queue is empty.
Implements RTT::internal::AtomicQueue< T >.
Definition at line 221 of file AtomicMWMRQueue.hpp.
|
inlinevirtual |
Inspect if the Queue is full.
Implements RTT::internal::AtomicQueue< T >.
Definition at line 207 of file AtomicMWMRQueue.hpp.
|
inlinevirtual |
Return the exact number of elements in the queue.
This is slow because it scans the whole queue.
Implements RTT::internal::AtomicQueue< T >.
Definition at line 242 of file AtomicMWMRQueue.hpp.