BloombergLP::bdlcc::Queue

This class provides a thread-enabled implementation of an efficient, in-place, indexable, double-ended queue of parameterized TYPE values. Very efficient access to the underlying bdlc::Queue object is provided, as well as to a bslmt::Mutex and a bslmt::Condition variable, to facilitate thread-safe use of the bdlc::Queue. Note that Queue is not a value-semantic type, but the underlying bdlc::Queue is. In this regard, Queue is a thread-enabled handle for a bdlc::Queue.

Synopsis

Declared in <bdlcc_queue.h>

template<class TYPE>
class Queue;

Types

NameDescription
InitialCapacity Enable uniform use of an optional integral constructor argument to specify the initial internal capacity (in items). For example, ` const Queue<int>::InitialCapacity NUM_ITEMS(8)); Queue<int> x(NUM_ITEMS); ` defines an instance x with an initial capacity of 8 items, but with a logical length of 0 items.

Member Functions

NameDescription
Queue [constructor]Constructors
~Queue [destructor]Destroy this container. The behavior is undefined unless all access or modification of the container has completed prior to this call.
condition Return a reference to the modifiable condition variable used by this queue to signal that the queue is not empty.
forcePushFront Append the specified item to the front of this queue without regard for the high-water mark. Note that this method is provided to allow high priority items to be inserted when the queue is full (i.e., has a number of items greater than or equal to its high-water mark); pushFront and pushBack should be used for general use.
highWaterMark Return the high-water mark value for this queue. Note that a negative value indicates no suggested-maximum capacity, and is not necessarily the same negative value that was passed to the constructor.
insertCondition Return a reference to the modifiable condition variable used by this queue to signal that the queue is not full (i.e., has fewer items than its high-water mark).
length Return the number of elements in this queue. Note that if other threads are manipulating the queue, this information may be obsolete by the time it is returned.
mutex Return a reference to the modifiable mutex used by this queue to synchronize access to its underlying bdlc::Queue object.
notEmptyCondition Return the condition variable used by this queue to signal that the queue is not empty.
notFullCondition Return the condition variable used by this queue to signal that the queue is not full (i.e., has fewer items than its high-water mark).
popBack popBack overloads
popFront popFront overloads
pushBack Append the specified item to the back of this queue. If the high-water mark is non-negative and the number of items in this queue is greater than or equal to the high-water mark, then block until the number of items in this queue is less than the high-water mark.
pushFront Append the specified item to the front of this queue. If the high-water mark is non-negative and the number of items in this queue is greater than or equal to the high-water mark, then block until the number of items in this queue is less than the high-water mark.
queue Return a reference to the modifiable underlying bdlc::Queue object used by this queue. Any access to the returned queue MUST first lock the associated mutex object (see the mutex method) in a multi-threaded environment. And when items are directly added to the queue returned by this method, the associated condition variable (see the condition method) should be signaled to notify any waiting threads of the availability of the new data.
removeAll removeAll overloads
timedPopBack Remove the last item in this queue and load that item value into the specified buffer. If this queue is empty, block until an item is available or until the specified timeout (expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. Return 0 on success, and a non-zero value if the call timed out before an item was available.
timedPopFront Remove the first item in this queue and load that item value into the specified buffer. If this queue is empty, block until an item is available or until the specified timeout (expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. Return 0 on success, and a non-zero value if the call timed out before an item was available.
timedPushBack Append the specified item to the back of this queue. If the high-water mark is non-negative and the number of items in this queue is greater than or equal to the high-water mark, then block until the number of items in this queue is less than the high-water mark or until the specified timeout (expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. Return 0 on success, and a non-zero value if the call timed out before the number of items in this queue fell below the high-water mark.
timedPushFront Append the specified item to the front of this queue. If the high water mark is non-negative and the number of items in this queue is greater than or equal to the high-water mark, then block until the number of items in this queue is less than the high-water mark or until the specified timeout (expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. Return 0 on success, and a non-zero value if the call timed out before the number of items in this queue fell below the high-water mark.
tryPopBack tryPopBack overloads
tryPopFront tryPopFront overloads
operator BloombergLP::bslmf::NestedTraitDeclaration<Queue, UsesBslmaAllocator> Declare that this type uses a bslma allocator.