Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::concurrent_bounded_queue< T, A > Class Template Reference

A high-performance thread-safe blocking concurrent bounded queue. More...

#include <concurrent_queue.h>

Inheritance diagram for tbb::concurrent_bounded_queue< T, A >:
Collaboration diagram for tbb::concurrent_bounded_queue< T, A >:

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 pageallocate_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

- Protected Types inherited from tbb::internal::concurrent_queue_base_v3
enum  copy_specifics { copy, move }
 
- Protected Member Functions inherited from tbb::internal::concurrent_queue_base_v8
 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...
 
- Protected Member Functions inherited from tbb::internal::concurrent_queue_base_v3
__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...
 
- Protected Attributes inherited from tbb::internal::concurrent_queue_base_v3
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...
 

Detailed Description

template<typename T, class A = cache_aligned_allocator<T>>
class tbb::concurrent_bounded_queue< T, A >

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.

Member Typedef Documentation

◆ allocator_type

template<typename T , class A = cache_aligned_allocator<T>>
typedef A tbb::concurrent_bounded_queue< T, A >::allocator_type

Allocator type.

Definition at line 285 of file concurrent_queue.h.

◆ const_iterator

template<typename T , class A = cache_aligned_allocator<T>>
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.

◆ const_reference

template<typename T , class A = cache_aligned_allocator<T>>
typedef const T& tbb::concurrent_bounded_queue< T, A >::const_reference

Const reference type.

Definition at line 291 of file concurrent_queue.h.

◆ copy_specifics

template<typename T , class A = cache_aligned_allocator<T>>
typedef concurrent_queue_base_v3::copy_specifics tbb::concurrent_bounded_queue< T, A >::copy_specifics
private

Definition at line 218 of file concurrent_queue.h.

◆ difference_type

template<typename T , class A = cache_aligned_allocator<T>>
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.

◆ iterator

template<typename T , class A = cache_aligned_allocator<T>>
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.

◆ padded_page

template<typename T , class A = cache_aligned_allocator<T>>
typedef concurrent_queue_base_v3::padded_page<T> tbb::concurrent_bounded_queue< T, A >::padded_page
private

Definition at line 217 of file concurrent_queue.h.

◆ page_allocator_type

template<typename T , class A = cache_aligned_allocator<T>>
typedef tbb::internal::allocator_rebind<A, char>::type tbb::concurrent_bounded_queue< T, A >::page_allocator_type
private

Definition at line 212 of file concurrent_queue.h.

◆ reference

template<typename T , class A = cache_aligned_allocator<T>>
typedef T& tbb::concurrent_bounded_queue< T, A >::reference

Reference type.

Definition at line 288 of file concurrent_queue.h.

◆ size_type

template<typename T , class A = cache_aligned_allocator<T>>
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.

◆ value_type

template<typename T , class A = cache_aligned_allocator<T>>
typedef T tbb::concurrent_bounded_queue< T, A >::value_type

Element type in the queue.

Definition at line 282 of file concurrent_queue.h.

Constructor & Destructor Documentation

◆ concurrent_bounded_queue() [1/5]

template<typename T , class A = cache_aligned_allocator<T>>
tbb::concurrent_bounded_queue< T, A >::concurrent_bounded_queue ( const allocator_type a = allocator_type())
inlineexplicit

Construct empty queue.

Definition at line 302 of file concurrent_queue.h.

302  :
303  concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
304  {
305  }
page_allocator_type my_allocator
Allocator type.

◆ concurrent_bounded_queue() [2/5]

template<typename T , class A = cache_aligned_allocator<T>>
tbb::concurrent_bounded_queue< T, A >::concurrent_bounded_queue ( const concurrent_bounded_queue< T, A > &  src,
const allocator_type a = allocator_type() 
)
inline

Copy constructor.

Definition at line 308 of file concurrent_queue.h.

309  : concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
310  {
311  assign( src );
312  }
page_allocator_type my_allocator
Allocator type.
void __TBB_EXPORTED_METHOD assign(const concurrent_queue_base_v3 &src)
copy internal representation

References tbb::internal::concurrent_queue_base_v3::assign().

Here is the call graph for this function:

◆ concurrent_bounded_queue() [3/5]

template<typename T , class A = cache_aligned_allocator<T>>
tbb::concurrent_bounded_queue< T, A >::concurrent_bounded_queue ( concurrent_bounded_queue< T, A > &&  src)
inline

Move constructors.

Definition at line 316 of file concurrent_queue.h.

317  : concurrent_queue_base_v8( sizeof(T) ), my_allocator( std::move(src.my_allocator) )
318  {
319  internal_swap( src );
320  }
void internal_swap(concurrent_queue_base_v3 &src)
swap queues
page_allocator_type my_allocator
Allocator type.
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319

◆ concurrent_bounded_queue() [4/5]

template<typename T , class A = cache_aligned_allocator<T>>
tbb::concurrent_bounded_queue< T, A >::concurrent_bounded_queue ( concurrent_bounded_queue< T, A > &&  src,
const allocator_type a 
)
inline

Definition at line 322 of file concurrent_queue.h.

323  : concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
324  {
325  // checking that memory allocated by one instance of allocator can be deallocated
326  // with another
327  if( my_allocator == src.my_allocator) {
328  this->internal_swap( src );
329  } else {
330  // allocators are different => performing per-element move
331  this->move_content( src );
332  src.clear();
333  }
334  }
void internal_swap(concurrent_queue_base_v3 &src)
swap queues
page_allocator_type my_allocator
Allocator type.
void __TBB_EXPORTED_METHOD move_content(concurrent_queue_base_v8 &src)
move items

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.

Here is the call graph for this function:

◆ concurrent_bounded_queue() [5/5]

template<typename T , class A = cache_aligned_allocator<T>>
template<typename InputIterator >
tbb::concurrent_bounded_queue< T, A >::concurrent_bounded_queue ( InputIterator  begin,
InputIterator  end,
const allocator_type a = allocator_type() 
)
inline

[begin,end) constructor

Definition at line 339 of file concurrent_queue.h.

341  : concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
342  {
343  for( ; begin != end; ++begin )
345  }
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp end
bool __TBB_EXPORTED_METHOD internal_push_if_not_full(const void *src)
Attempt to enqueue item onto queue using copy operation.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
page_allocator_type my_allocator
Allocator type.

References begin, end, and tbb::internal::concurrent_queue_base_v3::internal_push_if_not_full().

Here is the call graph for this function:

◆ ~concurrent_bounded_queue()

template<typename T , class A >
tbb::concurrent_bounded_queue< T, A >::~concurrent_bounded_queue ( )

Destroy queue.

Definition at line 461 of file concurrent_queue.h.

461  {
462  clear();
464 }
void __TBB_EXPORTED_METHOD internal_finish_clear()
free any remaining pages
void clear()
clear the queue. not thread-safe.

Member Function Documentation

◆ allocate_page()

template<typename T , class A = cache_aligned_allocator<T>>
virtual page* tbb::concurrent_bounded_queue< T, A >::allocate_page ( )
inlineprivatevirtual

custom allocator

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 267 of file concurrent_queue.h.

267  {
268  size_t n = sizeof(padded_page) + (items_per_page-1)*sizeof(T);
269  page *p = reinterpret_cast<page*>(my_allocator.allocate( n ));
270  if( !p )
272  return p;
273  }
concurrent_queue_base_v3::padded_page< T > padded_page
page_allocator_type my_allocator
Allocator type.
void const char const char int ITT_FORMAT __itt_group_sync p
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()

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().

Here is the call graph for this function:

◆ assign_and_destroy_item()

template<typename T , class A = cache_aligned_allocator<T>>
virtual void tbb::concurrent_bounded_queue< T, A >::assign_and_destroy_item ( void dst,
page src,
size_t  index 
)
inlineprivatevirtual

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 261 of file concurrent_queue.h.

261  {
262  T& from = get_ref(src,index);
263  destroyer d(from);
264  *static_cast<T*>(dst) = tbb::internal::move( from );
265  }
T & get_ref(page &p, size_t index)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319

References d, tbb::concurrent_bounded_queue< T, A >::get_ref(), and tbb::move().

Here is the call graph for this function:

◆ capacity()

template<typename T , class A = cache_aligned_allocator<T>>
size_type tbb::concurrent_bounded_queue< T, A >::capacity ( ) const
inline

Maximum number of allowed elements.

Definition at line 421 of file concurrent_queue.h.

421  {
422  return my_capacity;
423  }
ptrdiff_t my_capacity
Capacity of the queue.

References tbb::internal::concurrent_queue_base_v3::my_capacity.

◆ clear()

template<typename T , class A >
void tbb::concurrent_bounded_queue< T, A >::clear ( )

clear the queue. not thread-safe.

Definition at line 467 of file concurrent_queue.h.

467  {
468  T value;
469  while( try_pop(value) ) /*noop*/;
470 }
bool try_pop(T &destination)
Attempt to dequeue an item from head of queue.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

References value.

Referenced by tbb::concurrent_bounded_queue< T, A >::concurrent_bounded_queue().

Here is the caller graph for this function:

◆ copy_item()

template<typename T , class A = cache_aligned_allocator<T>>
virtual void tbb::concurrent_bounded_queue< T, A >::copy_item ( page dst,
size_t  index,
const void src 
)
inlineprivatevirtual

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 233 of file concurrent_queue.h.

233  {
234  new( &get_ref(dst,index) ) T(*static_cast<const T*>(src));
235  }
T & get_ref(page &p, size_t index)

References tbb::concurrent_bounded_queue< T, A >::get_ref().

Here is the call graph for this function:

◆ copy_page_item()

template<typename T , class A = cache_aligned_allocator<T>>
virtual void tbb::concurrent_bounded_queue< T, A >::copy_page_item ( page dst,
size_t  dindex,
const page src,
size_t  sindex 
)
inlineprivatevirtual

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 247 of file concurrent_queue.h.

247  {
248  new( &get_ref(dst,dindex) ) T( get_ref( const_cast<page&>(src), sindex ) );
249  }
T & get_ref(page &p, size_t index)

References tbb::concurrent_bounded_queue< T, A >::get_ref().

Here is the call graph for this function:

◆ deallocate_page()

template<typename T , class A = cache_aligned_allocator<T>>
virtual void tbb::concurrent_bounded_queue< T, A >::deallocate_page ( page p)
inlineprivatevirtual

custom de-allocator

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 275 of file concurrent_queue.h.

275  {
276  size_t n = sizeof(padded_page) + (items_per_page-1)*sizeof(T);
277  my_allocator.deallocate( reinterpret_cast<char*>(p), n );
278  }
concurrent_queue_base_v3::padded_page< T > padded_page
page_allocator_type my_allocator
Allocator type.
void const char const char int ITT_FORMAT __itt_group_sync p

References tbb::internal::concurrent_queue_base_v3::items_per_page, tbb::concurrent_bounded_queue< T, A >::my_allocator, and p.

◆ emplace()

template<typename T , class A = cache_aligned_allocator<T>>
template<typename... Arguments>
void tbb::concurrent_bounded_queue< T, A >::emplace ( Arguments &&...  args)
inline

Definition at line 363 of file concurrent_queue.h.

363  {
364  push( T(std::forward<Arguments>( args )...) );
365  }
void push(const T &source)
Enqueue an item at tail of queue.

References tbb::concurrent_bounded_queue< T, A >::push().

Here is the call graph for this function:

◆ empty()

template<typename T , class A = cache_aligned_allocator<T>>
bool tbb::concurrent_bounded_queue< T, A >::empty ( ) const
inline

Equivalent to size()<=0.

Definition at line 418 of file concurrent_queue.h.

418 {return internal_empty();}
bool __TBB_EXPORTED_METHOD internal_empty() const
Check if the queue is empty.

References tbb::internal::concurrent_queue_base_v3::internal_empty().

Here is the call graph for this function:

◆ get_allocator()

template<typename T , class A = cache_aligned_allocator<T>>
allocator_type tbb::concurrent_bounded_queue< T, A >::get_allocator ( ) const
inline

return allocator object

Definition at line 433 of file concurrent_queue.h.

433 { return this->my_allocator; }
page_allocator_type my_allocator
Allocator type.

References tbb::concurrent_bounded_queue< T, A >::my_allocator.

◆ get_ref()

template<typename T , class A = cache_aligned_allocator<T>>
T& tbb::concurrent_bounded_queue< T, A >::get_ref ( page p,
size_t  index 
)
inlineprivate

Definition at line 228 of file concurrent_queue.h.

228  {
229  __TBB_ASSERT( index<items_per_page, NULL );
230  return (&static_cast<padded_page*>(static_cast<void*>(&p))->last)[index];
231  }
auto last(Container &c) -> decltype(begin(c))
void const char const char int ITT_FORMAT __itt_group_sync p
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_item()

template<typename T , class A = cache_aligned_allocator<T>>
virtual void tbb::concurrent_bounded_queue< T, A >::move_item ( page dst,
size_t  index,
const void src 
)
inlineprivatevirtual

Implements tbb::internal::concurrent_queue_base_v8.

Definition at line 238 of file concurrent_queue.h.

238  {
239  new( &get_ref(dst,index) ) T( std::move(*static_cast<T*>(const_cast<void*>(src))) );
240  }
T & get_ref(page &p, size_t index)
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319

References tbb::concurrent_bounded_queue< T, A >::get_ref(), and tbb::move().

Here is the call graph for this function:

◆ move_page_item()

template<typename T , class A = cache_aligned_allocator<T>>
virtual void tbb::concurrent_bounded_queue< T, A >::move_page_item ( page dst,
size_t  dindex,
const page src,
size_t  sindex 
)
inlineprivatevirtual

Implements tbb::internal::concurrent_queue_base_v8.

Definition at line 252 of file concurrent_queue.h.

252  {
253  new( &get_ref(dst,dindex) ) T( std::move(get_ref( const_cast<page&>(src), sindex )) );
254  }
T & get_ref(page &p, size_t index)
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319

References tbb::concurrent_bounded_queue< T, A >::get_ref(), and tbb::move().

Here is the call graph for this function:

◆ pop()

template<typename T , class A = cache_aligned_allocator<T>>
void tbb::concurrent_bounded_queue< T, A >::pop ( T &  destination)
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.

371  {
372  internal_pop( &destination );
373  }
void __TBB_EXPORTED_METHOD internal_pop(void *dst)
Dequeue item from head of queue.

References tbb::internal::concurrent_queue_base_v3::internal_pop().

Here is the call graph for this function:

◆ push() [1/2]

template<typename T , class A = cache_aligned_allocator<T>>
void tbb::concurrent_bounded_queue< T, A >::push ( const T &  source)
inline

Enqueue an item at tail of queue.

Definition at line 351 of file concurrent_queue.h.

351  {
352  internal_push( &source );
353  }
void __TBB_EXPORTED_METHOD internal_push(const void *src)
Enqueue item at tail of queue using copy operation.

References tbb::internal::concurrent_queue_base_v3::internal_push().

Referenced by tbb::concurrent_bounded_queue< T, A >::emplace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push() [2/2]

template<typename T , class A = cache_aligned_allocator<T>>
void tbb::concurrent_bounded_queue< T, A >::push ( T &&  source)
inline

Move an item at tail of queue.

Definition at line 357 of file concurrent_queue.h.

357  {
358  internal_push_move( &source );
359  }
void __TBB_EXPORTED_METHOD internal_push_move(const void *src)
Enqueue item at tail of queue using move operation.

◆ set_capacity()

template<typename T , class A = cache_aligned_allocator<T>>
void tbb::concurrent_bounded_queue< T, A >::set_capacity ( size_type  new_capacity)
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.

428  {
429  internal_set_capacity( new_capacity, sizeof(T) );
430  }
void __TBB_EXPORTED_METHOD internal_set_capacity(ptrdiff_t capacity, size_t element_size)
Set the queue capacity.

References tbb::internal::concurrent_queue_base_v3::internal_set_capacity().

Here is the call graph for this function:

◆ size()

template<typename T , class A = cache_aligned_allocator<T>>
size_type tbb::concurrent_bounded_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.

Definition at line 415 of file concurrent_queue.h.

415 {return internal_size();}
ptrdiff_t __TBB_EXPORTED_METHOD internal_size() const
Get size of queue.

References tbb::internal::concurrent_queue_base_v3::internal_size().

Here is the call graph for this function:

◆ try_emplace()

template<typename T , class A = cache_aligned_allocator<T>>
template<typename... Arguments>
bool tbb::concurrent_bounded_queue< T, A >::try_emplace ( Arguments &&...  args)
inline

Definition at line 398 of file concurrent_queue.h.

398  {
399  return try_push( T(std::forward<Arguments>( args )...) );
400  }
bool try_push(const T &source)
Enqueue an item at tail of queue if queue is not already full.

References tbb::concurrent_bounded_queue< T, A >::try_push().

Here is the call graph for this function:

◆ try_pop()

template<typename T , class A = cache_aligned_allocator<T>>
bool tbb::concurrent_bounded_queue< T, A >::try_pop ( 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.

Definition at line 407 of file concurrent_queue.h.

407  {
408  return internal_pop_if_present( &destination );
409  }
bool __TBB_EXPORTED_METHOD internal_pop_if_present(void *dst)
Attempt to dequeue item from queue.

References tbb::internal::concurrent_queue_base_v3::internal_pop_if_present().

Here is the call graph for this function:

◆ try_push() [1/2]

template<typename T , class A = cache_aligned_allocator<T>>
bool tbb::concurrent_bounded_queue< T, A >::try_push ( 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.

Definition at line 385 of file concurrent_queue.h.

385  {
386  return internal_push_if_not_full( &source );
387  }
bool __TBB_EXPORTED_METHOD internal_push_if_not_full(const void *src)
Attempt to enqueue item onto queue using copy operation.

References tbb::internal::concurrent_queue_base_v3::internal_push_if_not_full().

Referenced by tbb::concurrent_bounded_queue< T, A >::try_emplace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_push() [2/2]

template<typename T , class A = cache_aligned_allocator<T>>
bool tbb::concurrent_bounded_queue< T, A >::try_push ( T &&  source)
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.

393  {
394  return internal_push_move_if_not_full( &source );
395  }
bool __TBB_EXPORTED_METHOD internal_push_move_if_not_full(const void *src)
Attempt to enqueue item onto queue using move operation.

References tbb::internal::concurrent_queue_base_v8::internal_push_move_if_not_full().

Here is the call graph for this function:

◆ unsafe_begin() [1/2]

template<typename T , class A = cache_aligned_allocator<T>>
iterator tbb::concurrent_bounded_queue< T, A >::unsafe_begin ( )
inline

Definition at line 444 of file concurrent_queue.h.

444 {return iterator(*this);}
internal::concurrent_queue_iterator< concurrent_bounded_queue, T > iterator

◆ unsafe_begin() [2/2]

template<typename T , class A = cache_aligned_allocator<T>>
const_iterator tbb::concurrent_bounded_queue< T, A >::unsafe_begin ( ) const
inline

Definition at line 446 of file concurrent_queue.h.

446 {return const_iterator(*this);}
internal::concurrent_queue_iterator< concurrent_bounded_queue, const T > const_iterator

◆ unsafe_end() [1/2]

template<typename T , class A = cache_aligned_allocator<T>>
iterator tbb::concurrent_bounded_queue< T, A >::unsafe_end ( )
inline

Definition at line 445 of file concurrent_queue.h.

445 {return iterator();}
internal::concurrent_queue_iterator< concurrent_bounded_queue, T > iterator

◆ unsafe_end() [2/2]

template<typename T , class A = cache_aligned_allocator<T>>
const_iterator tbb::concurrent_bounded_queue< T, A >::unsafe_end ( ) const
inline

Definition at line 447 of file concurrent_queue.h.

447 {return const_iterator();}
internal::concurrent_queue_iterator< concurrent_bounded_queue, const T > const_iterator

Friends And Related Function Documentation

◆ internal::concurrent_queue_iterator

template<typename T , class A = cache_aligned_allocator<T>>
template<typename Container , typename Value >
friend class internal::concurrent_queue_iterator
friend

Definition at line 211 of file concurrent_queue.h.

Member Data Documentation

◆ my_allocator


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

Copyright © 2005-2020 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.