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 207 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 282 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 436 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 288 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 215 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 296 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 435 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 214 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 209 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 285 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 293 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 279 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 299 of file concurrent_queue.h.

299  :
300  concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
301  {
302  }
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 305 of file concurrent_queue.h.

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

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 313 of file concurrent_queue.h.

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

◆ 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 319 of file concurrent_queue.h.

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

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 336 of file concurrent_queue.h.

338  : concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
339  {
340  for( ; begin != end; ++begin )
342  }
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
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
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 458 of file concurrent_queue.h.

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

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 264 of file concurrent_queue.h.

264  {
265  size_t n = sizeof(padded_page) + (items_per_page-1)*sizeof(T);
266  page *p = reinterpret_cast<page*>(my_allocator.allocate( n ));
267  if( !p )
269  return p;
270  }
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()
concurrent_queue_base_v3::padded_page< T > padded_page
page_allocator_type my_allocator
Allocator type.

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 258 of file concurrent_queue.h.

258  {
259  T& from = get_ref(src,index);
260  destroyer d(from);
261  *static_cast<T*>(dst) = tbb::internal::move( from );
262  }
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:305

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 418 of file concurrent_queue.h.

418  {
419  return my_capacity;
420  }
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 464 of file concurrent_queue.h.

464  {
465  T value;
466  while( try_pop(value) ) /*noop*/;
467 }
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
bool try_pop(T &destination)
Attempt to dequeue an item from head of queue.

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 230 of file concurrent_queue.h.

230  {
231  new( &get_ref(dst,index) ) T(*static_cast<const T*>(src));
232  }
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 244 of file concurrent_queue.h.

244  {
245  new( &get_ref(dst,dindex) ) T( get_ref( const_cast<page&>(src), sindex ) );
246  }
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 272 of file concurrent_queue.h.

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

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 360 of file concurrent_queue.h.

360  {
361  push( T(std::forward<Arguments>( args )...) );
362  }
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 415 of file concurrent_queue.h.

415 {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 430 of file concurrent_queue.h.

430 { 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 225 of file concurrent_queue.h.

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

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 235 of file concurrent_queue.h.

235  {
236  new( &get_ref(dst,index) ) T( std::move(*static_cast<T*>(const_cast<void*>(src))) );
237  }
T & get_ref(page &p, size_t index)
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:305

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 249 of file concurrent_queue.h.

249  {
250  new( &get_ref(dst,dindex) ) T( std::move(get_ref( const_cast<page&>(src), sindex )) );
251  }
T & get_ref(page &p, size_t index)
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:305

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 368 of file concurrent_queue.h.

368  {
369  internal_pop( &destination );
370  }
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 348 of file concurrent_queue.h.

348  {
349  internal_push( &source );
350  }
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 354 of file concurrent_queue.h.

354  {
355  internal_push_move( &source );
356  }
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 425 of file concurrent_queue.h.

425  {
426  internal_set_capacity( new_capacity, sizeof(T) );
427  }
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 412 of file concurrent_queue.h.

412 {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 395 of file concurrent_queue.h.

395  {
396  return try_push( T(std::forward<Arguments>( args )...) );
397  }
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 404 of file concurrent_queue.h.

404  {
405  return internal_pop_if_present( &destination );
406  }
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 382 of file concurrent_queue.h.

382  {
383  return internal_push_if_not_full( &source );
384  }
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 390 of file concurrent_queue.h.

390  {
391  return internal_push_move_if_not_full( &source );
392  }
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 441 of file concurrent_queue.h.

441 {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 443 of file concurrent_queue.h.

443 {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 442 of file concurrent_queue.h.

442 {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 444 of file concurrent_queue.h.

444 {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 208 of file concurrent_queue.h.

Member Data Documentation

◆ my_allocator


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

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