|
BDE 4.14.0 Production release
|
#include <bdlcc_queue.h>
Classes | |
| struct | InitialCapacity |
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION (Queue, bslma::UsesBslmaAllocator) | |
| Queue (bslma::Allocator *basicAllocator=0) | |
| Queue (int highWaterMark, bslma::Allocator *basicAllocator=0) | |
| Queue (const InitialCapacity &numItems, bslma::Allocator *basicAllocator=0) | |
| Queue (const InitialCapacity &numItems, int highWaterMark, bslma::Allocator *basicAllocator=0) | |
| Queue (const bdlc::Queue< TYPE > &srcQueue, bslma::Allocator *basicAllocator=0) | |
| Queue (const bdlc::Queue< TYPE > &srcQueue, int highWaterMark, bslma::Allocator *basicAllocator=0) | |
| ~Queue () | |
| void | popBack (TYPE *buffer) |
| TYPE | popBack () |
| int | timedPopBack (TYPE *buffer, const bsls::TimeInterval &timeout) |
| void | popFront (TYPE *buffer) |
| TYPE | popFront () |
| int | timedPopFront (TYPE *buffer, const bsls::TimeInterval &timeout) |
| void | removeAll () |
| void | removeAll (bsl::vector< TYPE > *buffer) |
| void | removeAll (std::vector< TYPE > *buffer) |
| void | pushBack (const TYPE &item) |
| void | pushFront (const TYPE &item) |
| int | timedPushBack (const TYPE &item, const bsls::TimeInterval &timeout) |
| int | timedPushFront (const TYPE &item, const bsls::TimeInterval &timeout) |
| void | forcePushFront (const TYPE &item) |
| int | tryPopFront (TYPE *buffer) |
| void | tryPopFront (int maxNumItems) |
| void | tryPopFront (int maxNumItems, bsl::vector< TYPE > *buffer) |
| void | tryPopFront (int maxNumItems, std::vector< TYPE > *buffer) |
| int | tryPopBack (TYPE *buffer) |
| void | tryPopBack (int maxNumItems) |
| void | tryPopBack (int maxNumItems, bsl::vector< TYPE > *buffer) |
| void | tryPopBack (int maxNumItems, std::vector< TYPE > *buffer) |
| bslmt::Condition & | condition () |
| bslmt::Condition & | insertCondition () |
| bslmt::Mutex & | mutex () |
| bslmt::Condition & | notEmptyCondition () |
| bslmt::Condition & | notFullCondition () |
| bdlc::Queue< TYPE > & | queue () |
| int | highWaterMark () const |
| int | length () const |
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.
See bdlcc_queue
|
inlineexplicit |
Create a queue of objects of parameterized TYPE. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
|
inlineexplicit |
Create a queue of objects of parameterized TYPE having either the specified highWaterMark suggested maximum length if highWaterMark is positive, or no maximum length if highWaterMark is negative. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless highWaterMark != 0.
|
inlineexplicit |
Create a queue of objects of parameterized TYPE with sufficient initial capacity to accommodate up to the specified numItems values without subsequent reallocation. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
|
inline |
Create a queue of objects of parameterized TYPE with sufficient initial capacity to accommodate up to the specified numItems values without subsequent reallocation and having either the specified highWaterMark suggested maximum length if highWaterMark is positive, or no maximum length if highWaterMark is negative. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless highWaterMark != 0.
|
inline |
Create a queue of objects of parameterized TYPE containing the sequence of TYPE values from the specified srcQueue. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
|
inline |
Create a queue of objects of parameterized TYPE containing the sequence of TYPE values from the specified srcQueue and having either the specified highWaterMark suggested maximum length if highWaterMark is positive, or no maximum length if highWaterMark is negative. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless highWaterMark != 0.
|
inline |
Destroy this container. The behavior is undefined unless all access or modification of the container has completed prior to this call.
| bdlcc::Queue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | Queue< TYPE > | , |
| bslma::UsesBslmaAllocator | |||
| ) |
|
inline |
Return a reference to the modifiable condition variable used by this queue to signal that the queue is not empty.
@DEPRECATED Use notEmptyCondition instead.
|
inline |
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.
|
inline |
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.
|
inline |
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).
@DEPRECATED Use notFullCondition instead.
|
inline |
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.
|
inline |
Return a reference to the modifiable mutex used by this queue to synchronize access to its underlying bdlc::Queue object.
|
inline |
Return the condition variable used by this queue to signal that the queue is not empty.
|
inline |
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).
| TYPE bdlcc::Queue< TYPE >::popBack | ( | ) |
Remove the last item in this queue and return that item value. If this queue is empty, block until an item is available.
| void bdlcc::Queue< TYPE >::popBack | ( | TYPE * | buffer | ) |
Remove the last item in this queue and load that item into the specified buffer. If this queue is empty, block until an item is available.
| TYPE bdlcc::Queue< TYPE >::popFront | ( | ) |
Remove the first item in this queue and return that item value. If the queue is empty, block until an item is available.
| void bdlcc::Queue< TYPE >::popFront | ( | TYPE * | buffer | ) |
Remove the first item in this queue and load that item into the specified buffer. If the queue is empty, block until an item is available.
| void bdlcc::Queue< TYPE >::pushBack | ( | const TYPE & | item | ) |
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.
| void bdlcc::Queue< TYPE >::pushFront | ( | const TYPE & | item | ) |
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.
|
inline |
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.
The (error-prone) usage of this method will be replaced by an appropriate smart-pointer-like proctor object in the future. Meanwhile, use this method with caution.
| void bdlcc::Queue< TYPE >::removeAll | ( | ) |
| void bdlcc::Queue< TYPE >::removeAll | ( | bsl::vector< TYPE > * | buffer | ) |
| void bdlcc::Queue< TYPE >::removeAll | ( | std::vector< TYPE > * | buffer | ) |
Remove all the items in this queue. If the optionally specified buffer is not 0, load into buffer a copy of the items removed in front to back order of the queue prior to removeAll.
| int bdlcc::Queue< TYPE >::timedPopBack | ( | TYPE * | buffer, |
| const bsls::TimeInterval & | timeout | ||
| ) |
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.
| int bdlcc::Queue< TYPE >::timedPopFront | ( | TYPE * | buffer, |
| const bsls::TimeInterval & | timeout | ||
| ) |
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.
| int bdlcc::Queue< TYPE >::timedPushBack | ( | const TYPE & | item, |
| const bsls::TimeInterval & | timeout | ||
| ) |
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.
| int bdlcc::Queue< TYPE >::timedPushFront | ( | const TYPE & | item, |
| const bsls::TimeInterval & | timeout | ||
| ) |
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.
|
inline |
|
inline |
|
inline |
| int bdlcc::Queue< TYPE >::tryPopBack | ( | TYPE * | buffer | ) |
If this queue is non-empty, remove the last item, load that item into the specified buffer, and return 0 indicating success. If this queue is empty, return a non-zero value with no effect on buffer or the state of this queue. This method never blocks.
|
inline |
|
inline |
|
inline |
| int bdlcc::Queue< TYPE >::tryPopFront | ( | TYPE * | buffer | ) |
If this queue is non-empty, remove the first item, load that item into the specified buffer, and return 0 indicating success. If this queue is empty, return a non-zero value with no effect on buffer or the state of this queue. This method never blocks.