tbb::concurrent_bounded_queue< T, A > Class Template Reference
Containers

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

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

inline explicit

Construct empty queue.

Definition at line 302 of file concurrent_queue.h.

:
concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
{
}
tbb::concurrent_bounded_queue::my_allocator
page_allocator_type my_allocator
Allocator type.
Definition: concurrent_queue.h:215
tbb::internal::concurrent_queue_base_v8::concurrent_queue_base_v8
concurrent_queue_base_v8(size_t item_sz)
Definition: _concurrent_queue_impl.h:942

## 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.

: concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
{
assign( src );
}
tbb::internal::concurrent_queue_base_v3::assign
void __TBB_EXPORTED_METHOD assign(const concurrent_queue_base_v3 &src)
copy internal representation
Definition: concurrent_queue.cpp:569

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.

: concurrent_queue_base_v8( sizeof(T) ), my_allocator( std::move(src.my_allocator) )
{
internal_swap( src );
}
tbb::move
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319
tbb::internal::concurrent_queue_base_v3::internal_swap
void internal_swap(concurrent_queue_base_v3 &src)
swap queues
Definition: _concurrent_queue_impl.h:917

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

Here is the call graph for this function:

## 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.

: concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
{
// checking that memory allocated by one instance of allocator can be deallocated
// with another
if( my_allocator == src.my_allocator) {
this->internal_swap( src );
} else {
// allocators are different => performing per-element move
this->move_content( src );
src.clear();
}
}
tbb::internal::concurrent_queue_base_v8::move_content
void __TBB_EXPORTED_METHOD move_content(concurrent_queue_base_v8 &src)
move items
Definition: concurrent_queue.cpp:573

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.

: concurrent_queue_base_v8( sizeof(T) ), my_allocator( a )
{
for( ; begin != end; ++begin )
internal_push_if_not_full(&*begin);
}
end
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
Definition: ittnotify_static.h:182
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 begin
Definition: ittnotify_static.h:182
tbb::internal::concurrent_queue_base_v3::internal_push_if_not_full
bool __TBB_EXPORTED_METHOD internal_push_if_not_full(const void *src)
Attempt to enqueue item onto queue using copy operation.
Definition: concurrent_queue.cpp:491

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.

{
clear();
internal_finish_clear();
}
tbb::concurrent_bounded_queue::clear
void clear()
clear the queue. not thread-safe.
Definition: concurrent_queue.h:467
tbb::internal::concurrent_queue_base_v3::internal_finish_clear
void __TBB_EXPORTED_METHOD internal_finish_clear()
free any remaining pages
Definition: concurrent_queue.cpp:535

## Member Function Documentation

## allocate_page()

template<typename T , class A = cache_aligned_allocator<T>>

virtual page* tbb::concurrent_bounded_queue< T, A >::allocate_page | ( |  | ) |

inline private virtual

custom allocator

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 267 of file concurrent_queue.h.

{
size_t n = sizeof(padded_page) + (items_per_page-1)*sizeof(T);
page *p = reinterpret_cast<page*>(my_allocator.allocate( n ));
if( !p )
internal::throw_exception(internal::eid_bad_alloc);
return p;
}
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91
tbb::internal::throw_exception
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
Definition: tbb_exception.h:105
tbb::internal::eid_bad_alloc
@ eid_bad_alloc
Definition: tbb_exception.h:68
tbb::concurrent_bounded_queue::padded_page
concurrent_queue_base_v3::padded_page< T > padded_page
Definition: concurrent_queue.h:217
tbb::internal::concurrent_queue_base_v3::items_per_page
size_t items_per_page
Always a power of 2.
Definition: _concurrent_queue_impl.h:847

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

inline private virtual

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 261 of file concurrent_queue.h.

{
T& from = get_ref(src,index);
destroyer d(from);
*static_cast<T*>(dst) = tbb::internal::move( from );
}
d
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
Definition: ittnotify_static.h:109
tbb::concurrent_bounded_queue::get_ref
T & get_ref(page &p, size_t index)
Definition: concurrent_queue.h:228

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.

{
return my_capacity;
}
tbb::internal::concurrent_queue_base_v3::my_capacity
ptrdiff_t my_capacity
Capacity of the queue.
Definition: _concurrent_queue_impl.h:844

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.

{
T value;
while( try_pop(value) ) /*noop*/;
}
value
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
Definition: ittnotify_static.h:192
tbb::concurrent_bounded_queue::try_pop
bool try_pop(T &destination)
Attempt to dequeue an item from head of queue.
Definition: concurrent_queue.h:407

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

inline private virtual

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 233 of file concurrent_queue.h.

{
new( &get_ref(dst,index) ) T(*static_cast<const T*>(src));
}

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

inline private virtual

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 247 of file concurrent_queue.h.

{
new( &get_ref(dst,dindex) ) T( get_ref( const_cast<page&>(src), sindex ) );
}

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

inline private virtual

custom de-allocator

Implements tbb::internal::concurrent_queue_base_v3.

Definition at line 275 of file concurrent_queue.h.

{
size_t n = sizeof(padded_page) + (items_per_page-1)*sizeof(T);
my_allocator.deallocate( reinterpret_cast<char*>(p), n );
}

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.

{
push( T(std::forward<Arguments>( args )...) );
}
tbb::concurrent_bounded_queue::push
void push(const T &source)
Enqueue an item at tail of queue.
Definition: concurrent_queue.h:351

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.

{return internal_empty();}
tbb::internal::concurrent_queue_base_v3::internal_empty
bool __TBB_EXPORTED_METHOD internal_empty() const
Check if the queue is empty.
Definition: concurrent_queue.cpp:524

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.

{ return this->my_allocator; }

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

inline private

Definition at line 228 of file concurrent_queue.h.

{
__TBB_ASSERT( index<items_per_page, NULL );
return (&static_cast<padded_page*>(static_cast<void*>(&p))->last)[index];
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::last
auto last(Container &c) -> decltype(begin(c))
Definition: _range_iterator.h:40

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

inline private virtual

Implements tbb::internal::concurrent_queue_base_v8.

Definition at line 238 of file concurrent_queue.h.

{
new( &get_ref(dst,index) ) T( std::move(*static_cast<T*>(const_cast<void*>(src))) );
}

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

inline private virtual

Implements tbb::internal::concurrent_queue_base_v8.

Definition at line 252 of file concurrent_queue.h.

{
new( &get_ref(dst,dindex) ) T( std::move(get_ref( const_cast<page&>(src), sindex )) );
}

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.

{
internal_pop( &destination );
}
tbb::internal::concurrent_queue_base_v3::internal_pop
void __TBB_EXPORTED_METHOD internal_pop(void *dst)
Dequeue item from head of queue.
Definition: concurrent_queue.cpp:414

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.

{
internal_push( &source );
}
tbb::internal::concurrent_queue_base_v3::internal_push
void __TBB_EXPORTED_METHOD internal_push(const void *src)
Enqueue item at tail of queue using copy operation.
Definition: concurrent_queue.cpp:363

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.

{
internal_push_move( &source );
}
tbb::internal::concurrent_queue_base_v8::internal_push_move
void __TBB_EXPORTED_METHOD internal_push_move(const void *src)
Enqueue item at tail of queue using move operation.
Definition: concurrent_queue.cpp:367

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

Here is the call graph for this function:

## 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.

{
internal_set_capacity( new_capacity, sizeof(T) );
}
tbb::internal::concurrent_queue_base_v3::internal_set_capacity
void __TBB_EXPORTED_METHOD internal_set_capacity(ptrdiff_t capacity, size_t element_size)
Set the queue capacity.
Definition: concurrent_queue.cpp:531

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.

{return internal_size();}
tbb::internal::concurrent_queue_base_v3::internal_size
ptrdiff_t __TBB_EXPORTED_METHOD internal_size() const
Get size of queue.
Definition: concurrent_queue.cpp:519

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.

{
return try_push( T(std::forward<Arguments>( args )...) );
}
tbb::concurrent_bounded_queue::try_push
bool try_push(const T &source)
Enqueue an item at tail of queue if queue is not already full.
Definition: concurrent_queue.h:385

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.

{
return internal_pop_if_present( &destination );
}
tbb::internal::concurrent_queue_base_v3::internal_pop_if_present
bool __TBB_EXPORTED_METHOD internal_pop_if_present(void *dst)
Attempt to dequeue item from queue.
Definition: concurrent_queue.cpp:467

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.

{
return internal_push_if_not_full( &source );
}

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.

{
return internal_push_move_if_not_full( &source );
}
tbb::internal::concurrent_queue_base_v8::internal_push_move_if_not_full
bool __TBB_EXPORTED_METHOD internal_push_move_if_not_full(const void *src)
Attempt to enqueue item onto queue using move operation.
Definition: concurrent_queue.cpp:495

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.

{return iterator(*this);}
tbb::concurrent_bounded_queue::iterator
internal::concurrent_queue_iterator< concurrent_bounded_queue, T > iterator
Definition: concurrent_queue.h:438

## 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.

{return const_iterator(*this);}
tbb::concurrent_bounded_queue::const_iterator
internal::concurrent_queue_iterator< concurrent_bounded_queue, const T > const_iterator
Definition: concurrent_queue.h:439

## 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.

{return 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.

{return 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

template<typename T , class A = cache_aligned_allocator<T>>

page_allocator_type tbb::concurrent_bounded_queue< T, A >::my_allocator

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

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

- concurrent_queue.h

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.