|
BDE 4.39.x Production Release
|
#include <bdlcc_fixedqueue.h>
This class provides a thread-aware, lock-free, fixed-size queue of values.
See bdlcc_fixedqueue
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION (FixedQueue, bslma::UsesBslmaAllocator) | |
| FixedQueue (bsl::size_t capacity, bslma::Allocator *basicAllocator=0) | |
| ~FixedQueue () | |
| int | pushBack (const TYPE &value) |
| int | pushBack (bslmf::MovableRef< TYPE > value) |
| int | tryPushBack (const TYPE &value) |
| int | tryPushBack (bslmf::MovableRef< TYPE > value) |
| void | popFront (TYPE *value) |
| TYPE | popFront () |
| int | tryPopFront (TYPE *value) |
| void | removeAll () |
| void | disable () |
| void | enable () |
| int | capacity () const |
| bool | isEmpty () const |
| bool | isEnabled () const |
| bool | isFull () const |
| int | numElements () const |
| int | length () const |
| int | size () const |
Friends | |
| template<class VAL > | |
| class | FixedQueue_PushProctor |
| template<class VAL > | |
| class | FixedQueue_PopGuard |
|
explicit |
Create a thread-aware lock-free queue having the specified capacity. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
0 < capacity and capacity <= bdlcc::FixedQueueIndexManager::k_MAX_CAPACITY. | bdlcc::FixedQueue< TYPE >::~FixedQueue | ( | ) |
Destroy this object.
| bdlcc::FixedQueue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | FixedQueue< TYPE > | , |
| bslma::UsesBslmaAllocator | |||
| ) |
|
inline |
Return the maximum number of elements that may be stored in this queue.
| void bdlcc::FixedQueue< TYPE >::disable | ( | ) |
Disable this queue. All subsequent invocations of pushBack or tryPushBack will fail immediately. All blocked invocations of pushBack will fail immediately. If the queue is already disabled, this method has no effect.
|
inline |
Enable queuing. If the queue is not disabled, this call has no effect.
|
inline |
Return true if this queue is empty (has no elements), or false otherwise.
|
inline |
Return true if this queue is enabled, and false otherwise.
|
inline |
Return true if this queue is full (when the number of elements currently in this queue equals its capacity), or false otherwise.
|
inline |
|
inline |
Returns the number of elements currently in this queue.
| TYPE bdlcc::FixedQueue< TYPE >::popFront | ( | ) |
Remove the element from the front of this queue and return it's value. If the queue is empty, block until it is not empty.
| void bdlcc::FixedQueue< TYPE >::popFront | ( | TYPE * | value | ) |
Remove the element from the front of this queue and load that element into the specified value. If the queue is empty, block until it is not empty.
| int bdlcc::FixedQueue< TYPE >::pushBack | ( | bslmf::MovableRef< TYPE > | value | ) |
Append the specified move-insertable value to the back of this queue, blocking until either space is available - if necessary - or the queue is disabled. value is left in a valid but unspecified state. Return 0 on success, and a nonzero value if the queue is disabled.
| int bdlcc::FixedQueue< TYPE >::pushBack | ( | const TYPE & | value | ) |
Append the specified value to the back of this queue, blocking until either space is available - if necessary - or the queue is disabled. Return 0 on success, and a nonzero value if the queue is disabled.
| void bdlcc::FixedQueue< TYPE >::removeAll | ( | ) |
Remove all items from this queue.
|
inline |
| int bdlcc::FixedQueue< TYPE >::tryPopFront | ( | TYPE * | value | ) |
Attempt to remove the element from the front of this queue without blocking, and, if successful, load the specified value with the removed element. Return 0 on success, and a non-zero value if queue was empty. On failure, value is not changed.
| int bdlcc::FixedQueue< TYPE >::tryPushBack | ( | bslmf::MovableRef< TYPE > | value | ) |
Attempt to append the specified move-insertable value to the back of this queue without blocking. value is left in a valid but unspecified state. Return 0 on success, and a non-zero value if the queue is full or disabled.
| int bdlcc::FixedQueue< TYPE >::tryPushBack | ( | const TYPE & | value | ) |
Attempt to append the specified value to the back of this queue without blocking. Return 0 on success, and a non-zero value if the queue is full or disabled.