Template class for queue with concurrent operations. This is the concurrent_queue supported in Intel® Threading Building Blocks (Intel® TBB) 2.1 and prior. New code should use the Intel® TBB 2.2 unbounded concurrent_queue or concurrent_bounded_queue.
template<typename T, typename Alloc=cache_aligned_allocator<T> > class concurrent_queue;
#include "tbb/concurrent_queue.h"
A tbb::deprecated::concurrent_queue is a bounded first-in first-out data structure that permits multiple threads to concurrently push and pop items. The default bounds are large enough to make the queue practically unbounded, subject to memory limitations on the target machine.
Compile with TBB_DEPRECATED=1 to inject tbb::deprecated::concurrent_queue into namespace tbb. Consider eventually migrating to the new queue classes.
Use the new tbb::concurrent_queue if you need only the non-blocking operations (push and try_pop) for modifying the queue.
Otherwise use the new tbb::concurrent_bounded_queue. It supports both blocking operations (push and try_pop) and non-blocking operations.
In both cases, use the new method names in the following table
namespace tbb { namespace deprecated { template<typename T, typename Alloc=cache_aligned_allocator<T> > class concurrent_queue { public: // types typedef T value_type; typedef T& reference; typedef const T& const_reference; typedef std::ptrdiff_t size_type; typedef std::ptrdiff_t difference_type; concurrent_queue(const Alloc& a = Alloc()); concurrent_queue(const concurrent_queue& src, const Alloc& a = Alloc()); template<typename InputIterator> concurrent_queue(InputIterator first, InputIterator last, const Alloc& a = Alloc()); ~concurrent_queue(); void push(const T& source); bool push_if_not_full(const T& source); void pop(T& destination); bool pop_if_present(T& destination); void clear(); size_type size() const; bool empty() const; size_t capacity() const; void set_capacity(size_type capacity); Alloc get_allocator() const; typedef implementation-defined iterator; typedef implementation-defined const_iterator; // iterators (these are slow and intended only for debugging) iterator begin(); iterator end(); const_iterator begin() const; const_iterator end() const; }; } #if TBB_DEPRECATED using deprecated::concurrent_queue; #else using strict_ppl::concurrent_queue; #endif }