#include <rtt/AtomicQueue.hpp>
No memory allocation is done during read or write, but the maximum number of threads which can access this object is defined by MAX_THREADS.
| T | The pointer type to be stored in the queue. Example : AtomicQueue<A*> is a queue which holds values of type A. | |
| ReadPolicy | The Policy to block (wait) on empty (during dequeue) using BlockingPolicy, or to return false, using NonBlockingPolicy (Default). This does not influence partial filled queue behaviour. | |
| WritePolicy | The Policy to block (wait) on full (during enqueue), using BlockingPolicy, or to return false, using NonBlockingPolicy (Default). This does not influence partial filled buffer behaviour. |
Definition at line 66 of file AtomicQueue.hpp.
Public Types | |
| typedef T | value_t |
| typedef unsigned int | size_type |
Public Member Functions | |
| AtomicQueue (unsigned int lsize, unsigned int threads=ORONUM_OS_MAX_THREADS) | |
| Create a lock-free queue wich can store lsize elements. | |
| ~AtomicQueue () | |
| size_type | capacity () const |
| size_type | size () const |
| bool | isEmpty () const |
| Inspect if the Queue is empty. | |
| bool | isFull () const |
| Inspect if the Queue is full. | |
| void | clear () |
| bool | enqueue (const T &value) |
| Enqueue an item. | |
| int | enqueueCounted (const T &value) |
| Enqueue an item and return its 'ticket' number. | |
| bool | dequeue (T &result) |
| Dequeue an item. | |
| int | dequeueCounted (T &result) |
| Dequeue an item and return the same 'ticket' number when it was queued. | |
| template<class MPoolType> | |
| T | lockfront (MPoolType &mp) const |
| Return the next to be read value and lock it in a MemoryPool, such that it is not freed. | |
| value_t | front () const |
| Returns the first element of the queue. | |
| value_t | back () const |
| Returns the last element of the queue. | |
Public Attributes | |
| const unsigned int | MAX_THREADS |
| AtomicQueue | ( | unsigned int | lsize, | |
| unsigned int | threads = ORONUM_OS_MAX_THREADS | |||
| ) | [inline] |
Create a lock-free queue wich can store lsize elements.
| lsize | the capacity of the queue. | |
| threads | the number of threads which may concurrently read or write this buffer. Defaults to ORONUM_OS_MAX_THREADS, but you may lower this number in case not all threads will read this buffer. A lower number will consume less memory. ' |
Definition at line 149 of file AtomicQueue.hpp.
| bool isEmpty | ( | ) | const [inline] |
Inspect if the Queue is empty.
Definition at line 184 of file AtomicQueue.hpp.
| bool isFull | ( | ) | const [inline] |
Inspect if the Queue is full.
Definition at line 197 of file AtomicQueue.hpp.
| bool enqueue | ( | const T & | value | ) | [inline] |
Enqueue an item.
| value | The value to enqueue. |
Definition at line 231 of file AtomicQueue.hpp.
Referenced by FixedSizeMemoryPool::deallocate(), AtomicQueue< T *, ReadPolicy, WritePolicy >::enqueueCounted(), and FixedSizeMemoryPool::make_pool().
| int enqueueCounted | ( | const T & | value | ) | [inline] |
Enqueue an item and return its 'ticket' number.
| value | The value to enqueue. |
Definition at line 262 of file AtomicQueue.hpp.
| bool dequeue | ( | T & | result | ) | [inline] |
Dequeue an item.
| result | The value dequeued. |
Definition at line 276 of file AtomicQueue.hpp.
Referenced by FixedSizeMemoryPool::allocate(), and AtomicQueue< T *, ReadPolicy, WritePolicy >::dequeueCounted().
| int dequeueCounted | ( | T & | result | ) | [inline] |
Dequeue an item and return the same 'ticket' number when it was queued.
| value | The value dequeued. |
Definition at line 310 of file AtomicQueue.hpp.
| T lockfront | ( | MPoolType & | mp | ) | const [inline] |
Return the next to be read value and lock it in a MemoryPool, such that it is not freed.
The returned pointer must be unlock()'ed by the user's code.
Definition at line 326 of file AtomicQueue.hpp.
| const unsigned int MAX_THREADS |
The maximum number of threads.
The number of threads which may concurrently access this buffer.
Definition at line 74 of file AtomicQueue.hpp.
1.5.3