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

#include <bdlcc_fixedqueue.h>

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (FixedQueue, bslma::UsesBslmaAllocator)
 
 FixedQueue (bsl::size_t capacity, bslma::Allocator *basicAllocator=0)
 
 ~FixedQueue ()
 Destroy this object.
 
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
 Returns the number of elements currently in this queue.
 
int length () const
 [DEPRECATED] Invoke numElements.
 
int size () const
 [DEPRECATED] Invoke capacity.
 

Friends

template<class VAL >
class FixedQueue_PushProctor
 
template<class VAL >
class FixedQueue_PopGuard
 

Detailed Description

template<class TYPE>
class bdlcc::FixedQueue< TYPE >

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

See bdlcc_fixedqueue

Constructor & Destructor Documentation

◆ FixedQueue()

template<class TYPE >
bdlcc::FixedQueue< TYPE >::FixedQueue ( bsl::size_t  capacity,
bslma::Allocator basicAllocator = 0 
)
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. The behavior is undefined unless 0 < capacity and capacity <= bdlcc::FixedQueueIndexManager::k_MAX_CAPACITY.

◆ ~FixedQueue()

template<class TYPE >
bdlcc::FixedQueue< TYPE >::~FixedQueue ( )

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ capacity()

template<class TYPE >
int bdlcc::FixedQueue< TYPE >::capacity ( ) const
inline

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

◆ disable()

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

◆ enable()

template<class TYPE >
void bdlcc::FixedQueue< TYPE >::enable ( )
inline

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

◆ isEmpty()

template<class TYPE >
bool bdlcc::FixedQueue< TYPE >::isEmpty ( ) const
inline

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

◆ isEnabled()

template<class TYPE >
bool bdlcc::FixedQueue< TYPE >::isEnabled ( ) const
inline

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

◆ isFull()

template<class TYPE >
bool bdlcc::FixedQueue< TYPE >::isFull ( ) const
inline

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

◆ length()

template<class TYPE >
int bdlcc::FixedQueue< TYPE >::length ( ) const
inline

◆ numElements()

template<class TYPE >
int bdlcc::FixedQueue< TYPE >::numElements ( ) const
inline

◆ popFront() [1/2]

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

◆ popFront() [2/2]

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

◆ pushBack() [1/2]

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

◆ pushBack() [2/2]

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

◆ removeAll()

template<class TYPE >
void bdlcc::FixedQueue< TYPE >::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()

template<class TYPE >
int bdlcc::FixedQueue< TYPE >::size ( ) const
inline

◆ tryPopFront()

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

◆ tryPushBack() [1/2]

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

◆ tryPushBack() [2/2]

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

Friends And Related Symbol Documentation

◆ FixedQueue_PopGuard

template<class TYPE >
template<class VAL >
friend class FixedQueue_PopGuard
friend

◆ FixedQueue_PushProctor

template<class TYPE >
template<class VAL >
friend class FixedQueue_PushProctor
friend

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