BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlcc::Queue< TYPE > Class Template Reference

#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::Conditioncondition ()
 
bslmt::ConditioninsertCondition ()
 
bslmt::Mutexmutex ()
 
bslmt::ConditionnotEmptyCondition ()
 
bslmt::ConditionnotFullCondition ()
 
bdlc::Queue< TYPE > & queue ()
 
int highWaterMark () const
 
int length () const
 

Detailed Description

template<class TYPE>
class bdlcc::Queue< TYPE >

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

Constructor & Destructor Documentation

◆ Queue() [1/6]

template<class TYPE >
bdlcc::Queue< TYPE >::Queue ( bslma::Allocator basicAllocator = 0)
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.

◆ Queue() [2/6]

template<class TYPE >
bdlcc::Queue< TYPE >::Queue ( int  highWaterMark,
bslma::Allocator basicAllocator = 0 
)
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.

◆ Queue() [3/6]

template<class TYPE >
bdlcc::Queue< TYPE >::Queue ( const InitialCapacity numItems,
bslma::Allocator basicAllocator = 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.

◆ Queue() [4/6]

template<class TYPE >
bdlcc::Queue< TYPE >::Queue ( const InitialCapacity numItems,
int  highWaterMark,
bslma::Allocator basicAllocator = 0 
)
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.

◆ Queue() [5/6]

template<class TYPE >
bdlcc::Queue< TYPE >::Queue ( const bdlc::Queue< TYPE > &  srcQueue,
bslma::Allocator basicAllocator = 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.

◆ Queue() [6/6]

template<class TYPE >
bdlcc::Queue< TYPE >::Queue ( const bdlc::Queue< TYPE > &  srcQueue,
int  highWaterMark,
bslma::Allocator basicAllocator = 0 
)
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.

◆ ~Queue()

template<class TYPE >
bdlcc::Queue< TYPE >::~Queue ( )
inline

Destroy this container. The behavior is undefined unless all access or modification of the container has completed prior to this call.

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

template<class TYPE >
bdlcc::Queue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( Queue< TYPE >  ,
bslma::UsesBslmaAllocator   
)

◆ condition()

template<class TYPE >
bslmt::Condition & bdlcc::Queue< TYPE >::condition ( )
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.

◆ forcePushFront()

template<class TYPE >
void bdlcc::Queue< TYPE >::forcePushFront ( const TYPE &  item)
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.

◆ highWaterMark()

template<class TYPE >
int bdlcc::Queue< TYPE >::highWaterMark ( ) const
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.

◆ insertCondition()

template<class TYPE >
bslmt::Condition & bdlcc::Queue< TYPE >::insertCondition ( )
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.

◆ length()

template<class TYPE >
int bdlcc::Queue< TYPE >::length ( ) const
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.

◆ mutex()

template<class TYPE >
bslmt::Mutex & bdlcc::Queue< TYPE >::mutex ( )
inline

Return a reference to the modifiable mutex used by this queue to synchronize access to its underlying bdlc::Queue object.

◆ notEmptyCondition()

template<class TYPE >
bslmt::Condition & bdlcc::Queue< TYPE >::notEmptyCondition ( )
inline

Return the condition variable used by this queue to signal that the queue is not empty.

◆ notFullCondition()

template<class TYPE >
bslmt::Condition & bdlcc::Queue< TYPE >::notFullCondition ( )
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).

◆ popBack() [1/2]

template<class TYPE >
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.

◆ popBack() [2/2]

template<class TYPE >
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.

◆ popFront() [1/2]

template<class TYPE >
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.

◆ popFront() [2/2]

template<class TYPE >
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.

◆ pushBack()

template<class TYPE >
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.

◆ pushFront()

template<class TYPE >
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.

◆ queue()

template<class TYPE >
bdlc::Queue< TYPE > & bdlcc::Queue< TYPE >::queue ( )
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.

◆ removeAll() [1/3]

template<class TYPE >
void bdlcc::Queue< TYPE >::removeAll ( )

◆ removeAll() [2/3]

template<class TYPE >
void bdlcc::Queue< TYPE >::removeAll ( bsl::vector< TYPE > *  buffer)

◆ removeAll() [3/3]

template<class TYPE >
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.

◆ timedPopBack()

template<class TYPE >
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.

◆ timedPopFront()

template<class TYPE >
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.

◆ timedPushBack()

template<class TYPE >
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.

◆ timedPushFront()

template<class TYPE >
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.

◆ tryPopBack() [1/4]

template<class TYPE >
void bdlcc::Queue< TYPE >::tryPopBack ( int  maxNumItems)
inline

◆ tryPopBack() [2/4]

template<class TYPE >
void bdlcc::Queue< TYPE >::tryPopBack ( int  maxNumItems,
bsl::vector< TYPE > *  buffer 
)
inline

◆ tryPopBack() [3/4]

template<class TYPE >
void bdlcc::Queue< TYPE >::tryPopBack ( int  maxNumItems,
std::vector< TYPE > *  buffer 
)
inline

◆ tryPopBack() [4/4]

template<class TYPE >
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.

◆ tryPopFront() [1/4]

template<class TYPE >
void bdlcc::Queue< TYPE >::tryPopFront ( int  maxNumItems)
inline

◆ tryPopFront() [2/4]

template<class TYPE >
void bdlcc::Queue< TYPE >::tryPopFront ( int  maxNumItems,
bsl::vector< TYPE > *  buffer 
)
inline

◆ tryPopFront() [3/4]

template<class TYPE >
void bdlcc::Queue< TYPE >::tryPopFront ( int  maxNumItems,
std::vector< TYPE > *  buffer 
)
inline

◆ tryPopFront() [4/4]

template<class TYPE >
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.


The documentation for this class was generated from the following file: