tbb::concurrent_queue< T, A > Class Template Reference
[Containers]

A high-performance thread-safe queue. More...

#include <concurrent_queue.h>

List of all members.

Public Types

typedef T value_type
 Element type in the queue.
typedef A allocator_type
 Allocator type.
typedef T & reference
 Reference type.
typedef const T & const_reference
 Const reference type.
typedef std::ptrdiff_t size_type
 Integral type for representing size of the queue.
typedef std::ptrdiff_t difference_type
 Difference type for iterator.
typedef internal::concurrent_queue_iterator<
concurrent_queue, T > 
iterator
typedef internal::concurrent_queue_iterator<
concurrent_queue, const T > 
const_iterator

Public Member Functions

 concurrent_queue (const allocator_type &a=allocator_type())
 Construct empty queue.
 ~concurrent_queue ()
 Destroy queue.
void push (const T &source)
 Enqueue an item at tail of queue.
void pop (T &destination)
 Dequeue item from head of queue.
bool push_if_not_full (const T &source)
 Enqueue an item at tail of queue if queue is not already full.
bool pop_if_present (T &destination)
 Attempt to dequeue an item from head of queue.
size_type size () const
 Return number of pushes minus number of pops.
bool empty () const
 Equivalent to size()<=0.
size_type capacity () const
 Maximum number of allowed elements.
void set_capacity (size_type capacity)
 Set the capacity.
allocator_type get_allocator () const
 return allocator object
void clear ()
 clear the queue. not thread-safe.
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
 concurrent_queue (const concurrent_queue &src, const allocator_type &a=allocator_type())
 Copy constructor.
template<typename InputIterator>
 concurrent_queue (InputIterator begin, InputIterator end, const allocator_type &a=allocator_type())
 [begin,end) constructor

Friends

class internal::concurrent_queue_iterator

Classes

class  destroyer
 Class used to ensure exception-safety of method "pop".


Detailed Description

template<typename T, class A>
class tbb::concurrent_queue< T, A >

A high-performance thread-safe queue.

Multiple threads may each push and pop concurrently. Assignment construction is not allowed.


Member Typedef Documentation

template<typename T, class A>
typedef std::ptrdiff_t tbb::concurrent_queue< T, A >::size_type

Integral type for representing size of the queue.

Notice that the size_type is a signed integral type. This is because the size can be negative if there are pending pops without corresponding pushes.


Member Function Documentation

template<typename T, class A>
void tbb::concurrent_queue< T, A >::pop ( T &  destination  )  [inline]

Dequeue item from head of queue.

Block until an item becomes available, and then dequeue it.

template<typename T, class A>
bool tbb::concurrent_queue< T, A >::pop_if_present ( T &  destination  )  [inline]

Attempt to dequeue an item from head of queue.

Does not wait for item to become available. Returns true if successful; false otherwise.

template<typename T, class A>
bool tbb::concurrent_queue< T, A >::push_if_not_full ( const T &  source  )  [inline]

Enqueue an item at tail of queue if queue is not already full.

Does not wait for queue to become not full. Returns true if item is pushed; false if queue was already full.

template<typename T, class A>
void tbb::concurrent_queue< T, A >::set_capacity ( size_type  capacity  )  [inline]

Set the capacity.

Setting the capacity to 0 causes subsequent push_if_not_full operations to always fail, and subsequent push operations to block forever.

template<typename T, class A>
size_type tbb::concurrent_queue< T, A >::size (  )  const [inline]

Return number of pushes minus number of pops.

Note that the result can be negative if there are pops waiting for the corresponding pushes. The result can also exceed capacity() if there are push operations in flight.


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

Copyright © 2005-2009 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.