This class provides a thread‐aware, lock‐free, fixed‐size queue of values.

Synopsis

Declared in <bdlcc_fixedqueue.h>

template<class TYPE>
class FixedQueue;

Member Functions

Name

Description

FixedQueue [constructor]

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. The behavior is undefined unless 0 < capacity and capacity <= bdlcc::FixedQueueIndexManager::k_MAX_CAPACITY.

~FixedQueue [destructor]

Destroy this object.

capacity

Return the maximum number of elements that may be stored in this queue.

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.

enable

Enable queuing. If the queue is not disabled, this call has no effect.

isEmpty

Return true if this queue is empty (has no elements), or false otherwise.

isEnabled

Return true if this queue is enabled, and false otherwise. Note that the queue is created in the "enabled" state.

isFull

Return true if this queue is full (when the number of elements currently in this queue equals its capacity), or false otherwise.

length

DEPRECATED: Use numElements() instead.

numElements

Returns the number of elements currently in this queue.

popFront

popFront overloads

pushBack

pushBack overloads

removeAll

Remove all items from this queue. Note that this operation is not atomic; if other threads are concurrently pushing items into the queue the result of numElements() after this function returns is not guaranteed to be 0.

size

DEPRECATED: Use capacity() instead.

tryPopFront

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.

tryPushBack

tryPushBack overloads

operator BloombergLP::bslmf::NestedTraitDeclaration<FixedQueue, UsesBslmaAllocator>

Declare that this type uses a bslma allocator.

Friends

Name

Description

BloombergLP::bdlcc::FixedQueue_PopGuard

This class provides a guard that, upon its destruction, will remove (pop) the indicated element from the FixedQueue object supplied at construction. Note that this guard is used to provide exception safety when popping an element from a FixedQueue object.

BloombergLP::bdlcc::FixedQueue_PushProctor

This class provides a proctor that, unless the release method has been previously invoked, will remove and destroy all the elements from a FixedQueue object supplied at construction (putting that ring‐buffer into a valid empty state) upon the proctor's destruction. Note that this guard is used to provide exception safety when pushing an element into a FixedQueue.

Created with MrDocs