Quick Links:

bal | bbl | bdl | bsl

Public Member Functions | Friends

bdlcc::FixedQueue< TYPE > Class Template Reference

#include <bdlcc_fixedqueue.h>

List of all members.

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (FixedQueue, bslma::UsesBslmaAllocator)
 FixedQueue (bsl::size_t capacity, bslma::Allocator *basicAllocator=0)
 ~FixedQueue ()
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
int length () const
int size () const

Friends

class FixedQueue_PushProctor
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 Component bdlcc_fixedqueue


Constructor & Destructor Documentation

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.

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

Destroy this object.


Member Function Documentation

template<class TYPE>
bdlcc::FixedQueue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( FixedQueue< TYPE >  ,
bslma::UsesBslmaAllocator   
)
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.

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.

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.

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.

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.

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.

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.

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.

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.

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

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

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

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

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

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

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

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

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

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

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

Returns the number of elements currently in this queue.

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

[!DEPRECATED!] Invoke numElements.

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

[!DEPRECATED!] Invoke capacity.


Friends And Related Function Documentation

template<class TYPE>
friend class FixedQueue_PushProctor [friend]
template<class TYPE>
friend class FixedQueue_PopGuard [friend]

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