Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
A high-performance thread-safe blocking concurrent bounded queue. More...
#include <concurrent_queue.h>
Classes | |
class | destroyer |
Class used to ensure exception-safety of method "pop". More... | |
Public Types | |
typedef T | value_type |
Element type in the queue. More... | |
typedef A | allocator_type |
Allocator type. More... | |
typedef T & | reference |
Reference type. More... | |
typedef const T & | const_reference |
Const reference type. More... | |
typedef std::ptrdiff_t | size_type |
Integral type for representing size of the queue. More... | |
typedef std::ptrdiff_t | difference_type |
Difference type for iterator. More... | |
typedef internal::concurrent_queue_iterator< concurrent_bounded_queue, T > | iterator |
typedef internal::concurrent_queue_iterator< concurrent_bounded_queue, const T > | const_iterator |
Public Member Functions | |
concurrent_bounded_queue (const allocator_type &a=allocator_type()) | |
Construct empty queue. More... | |
concurrent_bounded_queue (const concurrent_bounded_queue &src, const allocator_type &a=allocator_type()) | |
Copy constructor. More... | |
concurrent_bounded_queue (concurrent_bounded_queue &&src) | |
Move constructors. More... | |
concurrent_bounded_queue (concurrent_bounded_queue &&src, const allocator_type &a) | |
template<typename InputIterator > | |
concurrent_bounded_queue (InputIterator begin, InputIterator end, const allocator_type &a=allocator_type()) | |
[begin,end) constructor More... | |
~concurrent_bounded_queue () | |
Destroy queue. More... | |
void | push (const T &source) |
Enqueue an item at tail of queue. More... | |
void | push (T &&source) |
Move an item at tail of queue. More... | |
template<typename... Arguments> | |
void | emplace (Arguments &&... args) |
void | pop (T &destination) |
Dequeue item from head of queue. More... | |
bool | try_push (const T &source) |
Enqueue an item at tail of queue if queue is not already full. More... | |
bool | try_push (T &&source) |
Move an item at tail of queue if queue is not already full. More... | |
template<typename... Arguments> | |
bool | try_emplace (Arguments &&... args) |
bool | try_pop (T &destination) |
Attempt to dequeue an item from head of queue. More... | |
size_type | size () const |
Return number of pushes minus number of pops. More... | |
bool | empty () const |
Equivalent to size()<=0. More... | |
size_type | capacity () const |
Maximum number of allowed elements. More... | |
void | set_capacity (size_type new_capacity) |
Set the capacity. More... | |
allocator_type | get_allocator () const |
return allocator object More... | |
void | clear () |
clear the queue. not thread-safe. More... | |
iterator | unsafe_begin () |
iterator | unsafe_end () |
const_iterator | unsafe_begin () const |
const_iterator | unsafe_end () const |
Private Types | |
typedef tbb::internal::allocator_rebind< A, char >::type | page_allocator_type |
typedef concurrent_queue_base_v3::padded_page< T > | padded_page |
typedef concurrent_queue_base_v3::copy_specifics | copy_specifics |
Private Member Functions | |
T & | get_ref (page &p, size_t index) |
virtual void | copy_item (page &dst, size_t index, const void *src) __TBB_override |
virtual void | move_item (page &dst, size_t index, const void *src) __TBB_override |
virtual void | copy_page_item (page &dst, size_t dindex, const page &src, size_t sindex) __TBB_override |
virtual void | move_page_item (page &dst, size_t dindex, const page &src, size_t sindex) __TBB_override |
virtual void | assign_and_destroy_item (void *dst, page &src, size_t index) __TBB_override |
virtual page * | allocate_page () __TBB_override |
custom allocator More... | |
virtual void | deallocate_page (page *p) __TBB_override |
custom de-allocator More... | |
Private Attributes | |
page_allocator_type | my_allocator |
Allocator type. More... | |
Friends | |
template<typename Container , typename Value > | |
class | internal::concurrent_queue_iterator |
Additional Inherited Members | |
![]() | |
enum | copy_specifics { copy, move } |
![]() | |
concurrent_queue_base_v8 (size_t item_sz) | |
void __TBB_EXPORTED_METHOD | move_content (concurrent_queue_base_v8 &src) |
move items More... | |
bool __TBB_EXPORTED_METHOD | internal_push_move_if_not_full (const void *src) |
Attempt to enqueue item onto queue using move operation. More... | |
void __TBB_EXPORTED_METHOD | internal_push_move (const void *src) |
Enqueue item at tail of queue using move operation. More... | |
![]() | |
__TBB_EXPORTED_METHOD | concurrent_queue_base_v3 (size_t item_size) |
virtual __TBB_EXPORTED_METHOD | ~concurrent_queue_base_v3 () |
void __TBB_EXPORTED_METHOD | internal_push (const void *src) |
Enqueue item at tail of queue using copy operation. More... | |
void __TBB_EXPORTED_METHOD | internal_pop (void *dst) |
Dequeue item from head of queue. More... | |
void __TBB_EXPORTED_METHOD | internal_abort () |
Abort all pending queue operations. More... | |
bool __TBB_EXPORTED_METHOD | internal_push_if_not_full (const void *src) |
Attempt to enqueue item onto queue using copy operation. More... | |
bool __TBB_EXPORTED_METHOD | internal_pop_if_present (void *dst) |
Attempt to dequeue item from queue. More... | |
ptrdiff_t __TBB_EXPORTED_METHOD | internal_size () const |
Get size of queue. More... | |
bool __TBB_EXPORTED_METHOD | internal_empty () const |
Check if the queue is empty. More... | |
void __TBB_EXPORTED_METHOD | internal_set_capacity (ptrdiff_t capacity, size_t element_size) |
Set the queue capacity. More... | |
void __TBB_EXPORTED_METHOD | internal_finish_clear () |
free any remaining pages More... | |
void __TBB_EXPORTED_METHOD | internal_throw_exception () const |
throw an exception More... | |
void __TBB_EXPORTED_METHOD | assign (const concurrent_queue_base_v3 &src) |
copy internal representation More... | |
void | internal_swap (concurrent_queue_base_v3 &src) |
swap queues More... | |
void | internal_insert_item (const void *src, copy_specifics op_type) |
Enqueues item at tail of queue using specified operation (copy or move) More... | |
bool | internal_insert_if_not_full (const void *src, copy_specifics op_type) |
Attempts to enqueue at tail of queue using specified operation (copy or move) More... | |
void | internal_assign (const concurrent_queue_base_v3 &src, copy_specifics op_type) |
Assigns one queue to another using specified operation (copy or move) More... | |
![]() | |
ptrdiff_t | my_capacity |
Capacity of the queue. More... | |
size_t | items_per_page |
Always a power of 2. More... | |
size_t | item_size |
Size of an item. More... | |
A high-performance thread-safe blocking concurrent bounded queue.
This is the pre-PPL TBB concurrent queue which supports boundedness and blocking semantics. Note that method names agree with the PPL-style concurrent queue. Multiple threads may each push and pop concurrently. Assignment construction is not allowed.
Definition at line 210 of file concurrent_queue.h.
typedef A tbb::concurrent_bounded_queue< T, A >::allocator_type |
Allocator type.
Definition at line 285 of file concurrent_queue.h.
typedef internal::concurrent_queue_iterator<concurrent_bounded_queue,const T> tbb::concurrent_bounded_queue< T, A >::const_iterator |
Definition at line 439 of file concurrent_queue.h.
typedef const T& tbb::concurrent_bounded_queue< T, A >::const_reference |
Const reference type.
Definition at line 291 of file concurrent_queue.h.
|
private |
Definition at line 218 of file concurrent_queue.h.
typedef std::ptrdiff_t tbb::concurrent_bounded_queue< T, A >::difference_type |
Difference type for iterator.
Definition at line 299 of file concurrent_queue.h.
typedef internal::concurrent_queue_iterator<concurrent_bounded_queue,T> tbb::concurrent_bounded_queue< T, A >::iterator |
Definition at line 438 of file concurrent_queue.h.
|
private |
Definition at line 217 of file concurrent_queue.h.
|
private |
Definition at line 212 of file concurrent_queue.h.
typedef T& tbb::concurrent_bounded_queue< T, A >::reference |
Reference type.
Definition at line 288 of file concurrent_queue.h.
typedef std::ptrdiff_t tbb::concurrent_bounded_queue< T, A >::size_type |
Integral type for representing size of the queue.
Note 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.
Definition at line 296 of file concurrent_queue.h.
typedef T tbb::concurrent_bounded_queue< T, A >::value_type |
Element type in the queue.
Definition at line 282 of file concurrent_queue.h.
|
inlineexplicit |
Construct empty queue.
Definition at line 302 of file concurrent_queue.h.
|
inline |
Copy constructor.
Definition at line 308 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::assign().
|
inline |
Move constructors.
Definition at line 316 of file concurrent_queue.h.
|
inline |
Definition at line 322 of file concurrent_queue.h.
References tbb::concurrent_bounded_queue< T, A >::clear(), tbb::internal::concurrent_queue_base_v3::internal_swap(), tbb::internal::concurrent_queue_base_v8::move_content(), and tbb::concurrent_bounded_queue< T, A >::my_allocator.
|
inline |
[begin,end) constructor
Definition at line 339 of file concurrent_queue.h.
References begin, end, and tbb::internal::concurrent_queue_base_v3::internal_push_if_not_full().
tbb::concurrent_bounded_queue< T, A >::~concurrent_bounded_queue | ( | ) |
Destroy queue.
Definition at line 461 of file concurrent_queue.h.
|
inlineprivatevirtual |
custom allocator
Implements tbb::internal::concurrent_queue_base_v3.
Definition at line 267 of file concurrent_queue.h.
References tbb::internal::eid_bad_alloc, tbb::internal::concurrent_queue_base_v3::items_per_page, tbb::concurrent_bounded_queue< T, A >::my_allocator, p, and tbb::internal::throw_exception().
|
inlineprivatevirtual |
Implements tbb::internal::concurrent_queue_base_v3.
Definition at line 261 of file concurrent_queue.h.
References d, tbb::concurrent_bounded_queue< T, A >::get_ref(), and tbb::move().
|
inline |
Maximum number of allowed elements.
Definition at line 421 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::my_capacity.
void tbb::concurrent_bounded_queue< T, A >::clear | ( | ) |
clear the queue. not thread-safe.
Definition at line 467 of file concurrent_queue.h.
References value.
Referenced by tbb::concurrent_bounded_queue< T, A >::concurrent_bounded_queue().
|
inlineprivatevirtual |
Implements tbb::internal::concurrent_queue_base_v3.
Definition at line 233 of file concurrent_queue.h.
References tbb::concurrent_bounded_queue< T, A >::get_ref().
|
inlineprivatevirtual |
Implements tbb::internal::concurrent_queue_base_v3.
Definition at line 247 of file concurrent_queue.h.
References tbb::concurrent_bounded_queue< T, A >::get_ref().
|
inlineprivatevirtual |
custom de-allocator
Implements tbb::internal::concurrent_queue_base_v3.
Definition at line 275 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::items_per_page, tbb::concurrent_bounded_queue< T, A >::my_allocator, and p.
|
inline |
Definition at line 363 of file concurrent_queue.h.
References tbb::concurrent_bounded_queue< T, A >::push().
|
inline |
Equivalent to size()<=0.
Definition at line 418 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::internal_empty().
|
inline |
return allocator object
Definition at line 433 of file concurrent_queue.h.
References tbb::concurrent_bounded_queue< T, A >::my_allocator.
|
inlineprivate |
Definition at line 228 of file concurrent_queue.h.
References __TBB_ASSERT, tbb::internal::concurrent_queue_base_v3::items_per_page, tbb::internal::last(), and p.
Referenced by tbb::concurrent_bounded_queue< T, A >::assign_and_destroy_item(), tbb::concurrent_bounded_queue< T, A >::copy_item(), tbb::concurrent_bounded_queue< T, A >::copy_page_item(), tbb::concurrent_bounded_queue< T, A >::move_item(), and tbb::concurrent_bounded_queue< T, A >::move_page_item().
|
inlineprivatevirtual |
Implements tbb::internal::concurrent_queue_base_v8.
Definition at line 238 of file concurrent_queue.h.
References tbb::concurrent_bounded_queue< T, A >::get_ref(), and tbb::move().
|
inlineprivatevirtual |
Implements tbb::internal::concurrent_queue_base_v8.
Definition at line 252 of file concurrent_queue.h.
References tbb::concurrent_bounded_queue< T, A >::get_ref(), and tbb::move().
|
inline |
Dequeue item from head of queue.
Block until an item becomes available, and then dequeue it.
Definition at line 371 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::internal_pop().
|
inline |
Enqueue an item at tail of queue.
Definition at line 351 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::internal_push().
Referenced by tbb::concurrent_bounded_queue< T, A >::emplace().
|
inline |
Move an item at tail of queue.
Definition at line 357 of file concurrent_queue.h.
|
inline |
Set the capacity.
Setting the capacity to 0 causes subsequent try_push operations to always fail, and subsequent push operations to block forever.
Definition at line 428 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::internal_set_capacity().
|
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.
Definition at line 415 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::internal_size().
|
inline |
Definition at line 398 of file concurrent_queue.h.
References tbb::concurrent_bounded_queue< T, A >::try_push().
|
inline |
Attempt to dequeue an item from head of queue.
Does not wait for item to become available. Returns true if successful; false otherwise.
Definition at line 407 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::internal_pop_if_present().
|
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.
Definition at line 385 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v3::internal_push_if_not_full().
Referenced by tbb::concurrent_bounded_queue< T, A >::try_emplace().
|
inline |
Move 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.
Definition at line 393 of file concurrent_queue.h.
References tbb::internal::concurrent_queue_base_v8::internal_push_move_if_not_full().
|
inline |
Definition at line 444 of file concurrent_queue.h.
|
inline |
Definition at line 446 of file concurrent_queue.h.
|
inline |
Definition at line 445 of file concurrent_queue.h.
|
inline |
Definition at line 447 of file concurrent_queue.h.
|
friend |
Definition at line 211 of file concurrent_queue.h.
|
private |
Allocator type.
Definition at line 215 of file concurrent_queue.h.
Referenced by tbb::concurrent_bounded_queue< T, A >::allocate_page(), tbb::concurrent_bounded_queue< T, A >::concurrent_bounded_queue(), tbb::concurrent_bounded_queue< T, A >::deallocate_page(), and tbb::concurrent_bounded_queue< T, A >::get_allocator().