tbb::internal::concurrent_queue_base_v3 Class Referenceabstract
Containers

For internal use only. More...

`#include <_concurrent_queue_impl.h>`

Inheritance diagram for tbb::internal::concurrent_queue_base_v3:
Collaboration diagram for tbb::internal::concurrent_queue_base_v3:

## Classes

struct | padded_page
struct | page
| Prefix on a page. More...

## Protected Types

enum | copy_specifics { copy , move }

## Protected Member Functions

__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...
virtual page * | allocate_page ()=0
| custom allocator More...
virtual void | deallocate_page (page *p)=0
| custom de-allocator 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

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

## Private Member Functions

virtual void | copy_item (page &dst, size_t index, const void *src)=0
virtual void | assign_and_destroy_item (void *dst, page &src, size_t index)=0
virtual void | copy_page_item (page &dst, size_t dindex, const page &src, size_t sindex)=0
Private Member Functions inherited from tbb::internal::no_copy
| no_copy (const no_copy &)=delete
| no_copy ()=default

## Private Attributes

concurrent_queue_rep * | my_rep
| Internal representation. More...

## Friends

class | concurrent_queue_rep
struct | micro_queue
class | micro_queue_pop_finalizer
class | concurrent_queue_iterator_rep
class | concurrent_queue_iterator_base_v3

## Detailed Description

For internal use only.

Type-independent portion of concurrent_queue.

Definition at line 826 of file _concurrent_queue_impl.h.

## Member Enumeration Documentation

## copy_specifics

enum tbb::internal::concurrent_queue_base_v3::copy_specifics

protected

Enumerator
copy |
move |

Definition at line 852 of file _concurrent_queue_impl.h.

{ copy, move };
tbb::internal::concurrent_queue_base_v3::move
@ move
Definition: _concurrent_queue_impl.h:852
tbb::internal::concurrent_queue_base_v3::copy
@ copy
Definition: _concurrent_queue_impl.h:852

## Constructor & Destructor Documentation

## concurrent_queue_base_v3()

tbb::internal::concurrent_queue_base_v3::concurrent_queue_base_v3 | ( | size_t | item_size | ) |

protected

Definition at line 337 of file concurrent_queue.cpp.

{
items_per_page = item_sz<= 8 ? 32 :
item_sz<= 16 ? 16 :
item_sz<= 32 ? 8 :
item_sz<= 64 ? 4 :
item_sz<=128 ? 2 :
1;
my_capacity = size_t(-1)/(item_sz>1 ? item_sz : 2);
my_rep = cache_aligned_allocator<concurrent_queue_rep>().allocate(1);
__TBB_ASSERT( is_aligned(my_rep, NFS_GetLineSize()), "alignment error" );
__TBB_ASSERT( is_aligned(&my_rep->head_counter, NFS_GetLineSize()), "alignment error" );
__TBB_ASSERT( is_aligned(&my_rep->tail_counter, NFS_GetLineSize()), "alignment error" );
__TBB_ASSERT( is_aligned(&my_rep->array, NFS_GetLineSize()), "alignment error" );
std::memset(static_cast<void*>(my_rep),0,sizeof(concurrent_queue_rep));
new ( &my_rep->items_avail ) concurrent_monitor();
new ( &my_rep->slots_avail ) concurrent_monitor();
this->item_size = item_sz;
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::NFS_GetLineSize
size_t __TBB_EXPORTED_FUNC NFS_GetLineSize()
Cache/sector line size.
Definition: cache_aligned_allocator.cpp:167
tbb::internal::is_aligned
bool is_aligned(T *pointer, uintptr_t alignment)
A function to check if passed in pointer is aligned on a specific border.
Definition: tbb_stddef.h:370
tbb::internal::concurrent_queue_base_v3::my_rep
concurrent_queue_rep * my_rep
Internal representation.
Definition: _concurrent_queue_impl.h:829
tbb::internal::concurrent_queue_base_v3::item_size
size_t item_size
Size of an item.
Definition: _concurrent_queue_impl.h:850
tbb::internal::concurrent_queue_base_v3::my_capacity
ptrdiff_t my_capacity
Capacity of the queue.
Definition: _concurrent_queue_impl.h:844
tbb::internal::concurrent_queue_base_v3::concurrent_queue_rep
friend class concurrent_queue_rep
Definition: _concurrent_queue_impl.h:831
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
tbb::internal::concurrent_queue_rep::array
micro_queue array[n_queue]
Definition: concurrent_queue.cpp:137
tbb::internal::concurrent_queue_rep::items_avail
concurrent_monitor items_avail
Definition: concurrent_queue.cpp:130
tbb::internal::concurrent_queue_rep::head_counter
atomic< ticket > head_counter
Definition: concurrent_queue.cpp:129
tbb::internal::concurrent_queue_rep::tail_counter
atomic< ticket > tail_counter
Definition: concurrent_queue.cpp:134
tbb::internal::concurrent_queue_rep::slots_avail
concurrent_monitor slots_avail
Definition: concurrent_queue.cpp:135

References __TBB_ASSERT, tbb::cache_aligned_allocator< T >::allocate(), tbb::internal::concurrent_queue_rep::array, tbb::internal::concurrent_queue_rep::head_counter, tbb::internal::is_aligned(), item_size, tbb::internal::concurrent_queue_rep::items_avail, items_per_page, my_capacity, my_rep, tbb::internal::NFS_GetLineSize(), tbb::internal::concurrent_queue_rep::slots_avail, and tbb::internal::concurrent_queue_rep::tail_counter.

Here is the call graph for this function:

## ~concurrent_queue_base_v3()

tbb::internal::concurrent_queue_base_v3::~concurrent_queue_base_v3 | ( |  | ) |

protected virtual

Definition at line 356 of file concurrent_queue.cpp.

{
size_t nq = my_rep->n_queue;
for( size_t i=0; i<nq; i++ )
__TBB_ASSERT( my_rep->array[i].tail_page==NULL, "pages were not freed properly" );
cache_aligned_allocator<concurrent_queue_rep>().deallocate(my_rep,1);
}
tbb::internal::micro_queue::tail_page
atomic< page * > tail_page
Definition: concurrent_queue.cpp:55
tbb::internal::concurrent_queue_rep::n_queue
static const size_t n_queue
Must be power of 2.
Definition: concurrent_queue.cpp:122

References __TBB_ASSERT, tbb::internal::concurrent_queue_rep::array, tbb::cache_aligned_allocator< T >::deallocate(), my_rep, tbb::internal::concurrent_queue_rep::n_queue, and tbb::internal::micro_queue::tail_page.

Here is the call graph for this function:

## Member Function Documentation

## allocate_page()

virtual page* tbb::internal::concurrent_queue_base_v3::allocate_page | ( |  | ) |

protected pure virtual

custom allocator

Implemented in tbb::concurrent_bounded_queue< T, A >.

Referenced by tbb::internal::micro_queue::make_copy(), and tbb::internal::micro_queue::push().

Here is the caller graph for this function:

## assign()

void tbb::internal::concurrent_queue_base_v3::assign | ( | const concurrent_queue_base_v3 & | src | ) |

protected

copy internal representation

Definition at line 569 of file concurrent_queue.cpp.

{
internal_assign( src, copy );
}
tbb::internal::concurrent_queue_base_v3::internal_assign
void internal_assign(const concurrent_queue_base_v3 &src, copy_specifics op_type)
Assigns one queue to another using specified operation (copy or move)
Definition: concurrent_queue.cpp:551

References copy, and internal_assign().

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

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

## assign_and_destroy_item()

virtual void tbb::internal::concurrent_queue_base_v3::assign_and_destroy_item | ( | void * | dst,
|  | page & | src,
|  | size_t | index
| ) |  |

private pure virtual

Implemented in tbb::concurrent_bounded_queue< T, A >.

Referenced by tbb::internal::micro_queue::pop().

Here is the caller graph for this function:

## copy_item()

virtual void tbb::internal::concurrent_queue_base_v3::copy_item | ( | page & | dst,
|  | size_t | index,
|  | const void * | src
| ) |  |

private pure virtual

Implemented in tbb::concurrent_bounded_queue< T, A >.

Referenced by tbb::internal::micro_queue::push().

Here is the caller graph for this function:

## copy_page_item()

virtual void tbb::internal::concurrent_queue_base_v3::copy_page_item | ( | page & | dst,
|  | size_t | dindex,
|  | const page & | src,
|  | size_t | sindex
| ) |  |

private pure virtual

Implemented in tbb::concurrent_bounded_queue< T, A >.

Referenced by tbb::internal::micro_queue::make_copy().

Here is the caller graph for this function:

## deallocate_page()

virtual void tbb::internal::concurrent_queue_base_v3::deallocate_page | ( | page * | p | ) |

protected pure virtual

custom de-allocator

Implemented in tbb::concurrent_bounded_queue< T, A >.

Referenced by internal_finish_clear(), and tbb::internal::micro_queue_pop_finalizer::~micro_queue_pop_finalizer().

Here is the caller graph for this function:

## internal_abort()

void tbb::internal::concurrent_queue_base_v3::internal_abort | ( |  | ) |

protected

Abort all pending queue operations.

Definition at line 460 of file concurrent_queue.cpp.

{
concurrent_queue_rep& r = *my_rep;
++r.abort_counter;
r.items_avail.abort_all();
r.slots_avail.abort_all();
}
tbb::internal::concurrent_queue_rep::abort_counter
atomic< unsigned > abort_counter
Definition: concurrent_queue.cpp:144

References tbb::internal::concurrent_monitor::abort_all(), tbb::internal::concurrent_queue_rep::abort_counter, tbb::internal::concurrent_queue_rep::items_avail, my_rep, and tbb::internal::concurrent_queue_rep::slots_avail.

Here is the call graph for this function:

## internal_assign()

void tbb::internal::concurrent_queue_base_v3::internal_assign | ( | const concurrent_queue_base_v3 & | src,
|  | copy_specifics | op_type
| ) |  |

protected

Assigns one queue to another using specified operation (copy or move)

Definition at line 551 of file concurrent_queue.cpp.

{
items_per_page = src.items_per_page;
my_capacity = src.my_capacity;
// copy concurrent_queue_rep.
my_rep->head_counter = src.my_rep->head_counter;
my_rep->tail_counter = src.my_rep->tail_counter;
my_rep->n_invalid_entries = src.my_rep->n_invalid_entries;
my_rep->abort_counter = src.my_rep->abort_counter;
// copy micro_queues
for( size_t i = 0; i<my_rep->n_queue; ++i )
my_rep->array[i].assign( src.my_rep->array[i], *this, op_type );
__TBB_ASSERT( my_rep->head_counter==src.my_rep->head_counter && my_rep->tail_counter==src.my_rep->tail_counter,
"the source concurrent queue should not be concurrently modified." );
}
tbb::internal::micro_queue::assign
micro_queue & assign(const micro_queue &src, concurrent_queue_base &base, concurrent_queue_base::copy_specifics op_type)
Definition: concurrent_queue.cpp:253
tbb::internal::concurrent_queue_rep::n_invalid_entries
atomic< size_t > n_invalid_entries
Definition: concurrent_queue.cpp:131

References __TBB_ASSERT, tbb::internal::concurrent_queue_rep::abort_counter, tbb::internal::concurrent_queue_rep::array, tbb::internal::micro_queue::assign(), tbb::internal::concurrent_queue_rep::head_counter, items_per_page, my_capacity, my_rep, tbb::internal::concurrent_queue_rep::n_invalid_entries, tbb::internal::concurrent_queue_rep::n_queue, and tbb::internal::concurrent_queue_rep::tail_counter.

Referenced by assign(), and tbb::internal::concurrent_queue_base_v8::move_content().

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

## internal_empty()

bool tbb::internal::concurrent_queue_base_v3::internal_empty | ( |  | ) | const

protected

Check if the queue is empty.

Definition at line 524 of file concurrent_queue.cpp.

{
ticket tc = my_rep->tail_counter;
ticket hc = my_rep->head_counter;
// if tc!=r.tail_counter, the queue was not empty at some point between the two reads.
return ( tc==my_rep->tail_counter && ptrdiff_t(tc-hc-my_rep->n_invalid_entries)<=0 );
}
tbb::internal::ticket
size_t ticket
Definition: concurrent_queue.cpp:42

References tbb::internal::concurrent_queue_rep::head_counter, my_rep, tbb::internal::concurrent_queue_rep::n_invalid_entries, and tbb::internal::concurrent_queue_rep::tail_counter.

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

Here is the caller graph for this function:

## internal_finish_clear()

void tbb::internal::concurrent_queue_base_v3::internal_finish_clear | ( |  | ) |

protected

free any remaining pages

Definition at line 535 of file concurrent_queue.cpp.

{
size_t nq = my_rep->n_queue;
for( size_t i=0; i<nq; ++i ) {
page* tp = my_rep->array[i].tail_page;
__TBB_ASSERT( my_rep->array[i].head_page==tp, "at most one page should remain" );
if( tp!=NULL) {
if( tp!=static_invalid_page ) deallocate_page( tp );
my_rep->array[i].tail_page = NULL;
}
}
}
tbb::internal::static_invalid_page
static void * static_invalid_page
Definition: concurrent_queue.cpp:156
tbb::internal::concurrent_queue_base_v3::deallocate_page
virtual void deallocate_page(page *p)=0
custom de-allocator
tbb::internal::micro_queue::head_page
atomic< page * > head_page
Definition: concurrent_queue.cpp:52

References __TBB_ASSERT, tbb::internal::concurrent_queue_rep::array, deallocate_page(), tbb::internal::micro_queue::head_page, my_rep, tbb::internal::concurrent_queue_rep::n_queue, tbb::internal::static_invalid_page, and tbb::internal::micro_queue::tail_page.

Here is the call graph for this function:

## internal_insert_if_not_full()

bool tbb::internal::concurrent_queue_base_v3::internal_insert_if_not_full | ( | const void * | src,
|  | copy_specifics | op_type
| ) |  |

protected

Attempts to enqueue at tail of queue using specified operation (copy or move)

Definition at line 499 of file concurrent_queue.cpp.

{
concurrent_queue_rep& r = *my_rep;
ticket k = r.tail_counter;
for(;;) {
if( (ptrdiff_t)(k-r.head_counter)>=my_capacity ) {
// Queue is full
return false;
}
// Queue had empty slot with ticket k when we looked. Attempt to claim that slot.
ticket tk=k;
k = r.tail_counter.compare_and_swap( tk+1, tk );
if( k==tk )
break;
// Another thread claimed the slot, so retry.
}
r.choose(k).push(src, k, *this, op_type);
r.items_avail.notify( predicate_leq(k) );
return true;
}

References tbb::internal::concurrent_queue_rep::choose(), tbb::internal::concurrent_queue_rep::head_counter, tbb::internal::concurrent_queue_rep::items_avail, my_capacity, my_rep, tbb::internal::concurrent_monitor::notify(), tbb::internal::micro_queue::push(), and tbb::internal::concurrent_queue_rep::tail_counter.

Referenced by internal_push_if_not_full(), and tbb::internal::concurrent_queue_base_v8::internal_push_move_if_not_full().

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

## internal_insert_item()

void tbb::internal::concurrent_queue_base_v3::internal_insert_item | ( | const void * | src,
|  | copy_specifics | op_type
| ) |  |

protected

Enqueues item at tail of queue using specified operation (copy or move)

Definition at line 371 of file concurrent_queue.cpp.

{
concurrent_queue_rep& r = *my_rep;
unsigned old_abort_counter = r.abort_counter;
ticket k = r.tail_counter++;
ptrdiff_t e = my_capacity;
#if DO_ITT_NOTIFY
bool sync_prepare_done = false;
#endif
if( (ptrdiff_t)(k-r.head_counter)>=e ) { // queue is full
#if DO_ITT_NOTIFY
if( !sync_prepare_done ) {
ITT_NOTIFY( sync_prepare, &sync_prepare_done );
sync_prepare_done = true;
}
#endif
bool slept = false;
concurrent_monitor::thread_context thr_ctx;
r.slots_avail.prepare_wait( thr_ctx, ((ptrdiff_t)(k-e)) );
while( (ptrdiff_t)(k-r.head_counter)>=const_cast<volatile ptrdiff_t&>(e = my_capacity) ) {
__TBB_TRY {
if( r.abort_counter!=old_abort_counter ) {
r.slots_avail.cancel_wait( thr_ctx );
throw_exception( eid_user_abort );
}
slept = r.slots_avail.commit_wait( thr_ctx );
} __TBB_CATCH( tbb::user_abort& ) {
r.choose(k).abort_push(k, *this);
__TBB_RETHROW();
} __TBB_CATCH(...) {
__TBB_RETHROW();
}
if (slept == true) break;
r.slots_avail.prepare_wait( thr_ctx, ((ptrdiff_t)(k-e)) );
}
if( !slept )
r.slots_avail.cancel_wait( thr_ctx );
}
ITT_NOTIFY( sync_acquired, &sync_prepare_done );
__TBB_ASSERT( (ptrdiff_t)(k-r.head_counter)<my_capacity, NULL);
r.choose( k ).push( src, k, *this, op_type );
r.items_avail.notify( predicate_leq(k) );
}
__TBB_CATCH
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:284
__TBB_TRY
#define __TBB_TRY
Definition: tbb_stddef.h:283
__TBB_RETHROW
#define __TBB_RETHROW()
Definition: tbb_stddef.h:286
ITT_NOTIFY
#define ITT_NOTIFY(name, obj)
Definition: itt_notify.h:112
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_user_abort
@ eid_user_abort
Definition: tbb_exception.h:85
tbb::user_abort
Exception for user-initiated abort.
Definition: tbb_exception.h:46

References __TBB_ASSERT, __TBB_CATCH, __TBB_RETHROW, __TBB_TRY, tbb::internal::concurrent_queue_rep::abort_counter, tbb::internal::micro_queue::abort_push(), tbb::internal::concurrent_monitor::cancel_wait(), tbb::internal::concurrent_queue_rep::choose(), tbb::internal::concurrent_monitor::commit_wait(), tbb::internal::eid_user_abort, tbb::internal::concurrent_queue_rep::head_counter, tbb::internal::concurrent_queue_rep::items_avail, ITT_NOTIFY, my_capacity, my_rep, tbb::internal::concurrent_monitor::notify(), tbb::internal::concurrent_monitor::prepare_wait(), tbb::internal::micro_queue::push(), tbb::internal::concurrent_queue_rep::slots_avail, tbb::internal::concurrent_queue_rep::tail_counter, and tbb::internal::throw_exception().

Referenced by internal_push(), and tbb::internal::concurrent_queue_base_v8::internal_push_move().

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

## internal_pop()

void tbb::internal::concurrent_queue_base_v3::internal_pop | ( | void * | dst | ) |

protected

Dequeue item from head of queue.

Definition at line 414 of file concurrent_queue.cpp.

{
concurrent_queue_rep& r = *my_rep;
ticket k;
#if DO_ITT_NOTIFY
bool sync_prepare_done = false;
#endif
unsigned old_abort_counter = r.abort_counter;
// This loop is a single pop operation; abort_counter should not be re-read inside
do {
k=r.head_counter++;
if ( (ptrdiff_t)(r.tail_counter-k)<=0 ) { // queue is empty
#if DO_ITT_NOTIFY
if( !sync_prepare_done ) {
ITT_NOTIFY( sync_prepare, dst );
sync_prepare_done = true;
}
#endif
bool slept = false;
concurrent_monitor::thread_context thr_ctx;
r.items_avail.prepare_wait( thr_ctx, k );
while( (ptrdiff_t)(r.tail_counter-k)<=0 ) {
__TBB_TRY {
if( r.abort_counter!=old_abort_counter ) {
r.items_avail.cancel_wait( thr_ctx );
throw_exception( eid_user_abort );
}
slept = r.items_avail.commit_wait( thr_ctx );
} __TBB_CATCH( tbb::user_abort& ) {
r.head_counter--;
__TBB_RETHROW();
} __TBB_CATCH(...) {
__TBB_RETHROW();
}
if (slept == true) break;
r.items_avail.prepare_wait( thr_ctx, k );
}
if( !slept )
r.items_avail.cancel_wait( thr_ctx );
}
__TBB_ASSERT((ptrdiff_t)(r.tail_counter-k)>0, NULL);
} while( !r.choose(k).pop(dst,k,*this) );
// wake up a producer..
r.slots_avail.notify( predicate_leq(k) );
}

References __TBB_ASSERT, __TBB_CATCH, __TBB_RETHROW, __TBB_TRY, tbb::internal::concurrent_queue_rep::abort_counter, tbb::internal::concurrent_monitor::cancel_wait(), tbb::internal::concurrent_queue_rep::choose(), tbb::internal::concurrent_monitor::commit_wait(), tbb::internal::eid_user_abort, tbb::internal::concurrent_queue_rep::head_counter, tbb::internal::concurrent_queue_rep::items_avail, ITT_NOTIFY, my_rep, tbb::internal::concurrent_monitor::notify(), tbb::internal::micro_queue::pop(), tbb::internal::concurrent_monitor::prepare_wait(), tbb::internal::concurrent_queue_rep::slots_avail, tbb::internal::concurrent_queue_rep::tail_counter, and tbb::internal::throw_exception().

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

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

## internal_pop_if_present()

bool tbb::internal::concurrent_queue_base_v3::internal_pop_if_present | ( | void * | dst | ) |

protected

Attempt to dequeue item from queue.

NULL if there was no item to dequeue.

Definition at line 467 of file concurrent_queue.cpp.

{
concurrent_queue_rep& r = *my_rep;
ticket k;
do {
k = r.head_counter;
for(;;) {
if( (ptrdiff_t)(r.tail_counter-k)<=0 ) {
// Queue is empty
return false;
}
// Queue had item with ticket k when we looked. Attempt to get that item.
ticket tk=k;
k = r.head_counter.compare_and_swap( tk+1, tk );
if( k==tk )
break;
// Another thread snatched the item, retry.
}
} while( !r.choose( k ).pop( dst, k, *this ) );
r.slots_avail.notify( predicate_leq(k) );
return true;
}

References tbb::internal::concurrent_queue_rep::choose(), tbb::internal::concurrent_queue_rep::head_counter, my_rep, tbb::internal::concurrent_monitor::notify(), tbb::internal::micro_queue::pop(), tbb::internal::concurrent_queue_rep::slots_avail, and tbb::internal::concurrent_queue_rep::tail_counter.

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

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

## internal_push()

void tbb::internal::concurrent_queue_base_v3::internal_push | ( | const void * | src | ) |

protected

Enqueue item at tail of queue using copy operation.

Definition at line 363 of file concurrent_queue.cpp.

{
internal_insert_item( src, copy );
}
tbb::internal::concurrent_queue_base_v3::internal_insert_item
void internal_insert_item(const void *src, copy_specifics op_type)
Enqueues item at tail of queue using specified operation (copy or move)
Definition: concurrent_queue.cpp:371

References copy, and internal_insert_item().

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

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

## internal_push_if_not_full()

bool tbb::internal::concurrent_queue_base_v3::internal_push_if_not_full | ( | const void * | src | ) |

protected

Attempt to enqueue item onto queue using copy operation.

Definition at line 491 of file concurrent_queue.cpp.

{
return internal_insert_if_not_full( src, copy );
}
tbb::internal::concurrent_queue_base_v3::internal_insert_if_not_full
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)
Definition: concurrent_queue.cpp:499

References copy, and internal_insert_if_not_full().

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

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

## internal_set_capacity()

void tbb::internal::concurrent_queue_base_v3::internal_set_capacity | ( | ptrdiff_t | capacity,
|  | size_t | element_size
| ) |  |

protected

Set the queue capacity.

Definition at line 531 of file concurrent_queue.cpp.

{
my_capacity = capacity<0 ? concurrent_queue_rep::infinite_capacity : capacity;
}
tbb::internal::concurrent_queue_rep::infinite_capacity
static const ptrdiff_t infinite_capacity
Value for effective_capacity that denotes unbounded queue.
Definition: concurrent_queue.cpp:147

References tbb::internal::concurrent_queue_rep::infinite_capacity, and my_capacity.

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

Here is the caller graph for this function:

## internal_size()

ptrdiff_t tbb::internal::concurrent_queue_base_v3::internal_size | ( |  | ) | const

protected

Get size of queue.

Definition at line 519 of file concurrent_queue.cpp.

{
__TBB_ASSERT( sizeof(ptrdiff_t)<=sizeof(size_t), NULL );
return ptrdiff_t(my_rep->tail_counter-my_rep->head_counter-my_rep->n_invalid_entries);
}

References __TBB_ASSERT, tbb::internal::concurrent_queue_rep::head_counter, my_rep, tbb::internal::concurrent_queue_rep::n_invalid_entries, and tbb::internal::concurrent_queue_rep::tail_counter.

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

Here is the caller graph for this function:

## internal_swap()

void tbb::internal::concurrent_queue_base_v3::internal_swap | ( | concurrent_queue_base_v3 & | src | ) |

inline protected

swap queues

Definition at line 917 of file _concurrent_queue_impl.h.

{
std::swap( my_capacity, src.my_capacity );
std::swap( items_per_page, src.items_per_page );
std::swap( item_size, src.item_size );
std::swap( my_rep, src.my_rep );
}
tbb::internal::swap
void swap(atomic< T > &lhs, atomic< T > &rhs)
Definition: atomic.h:564

References item_size, items_per_page, my_capacity, tbb::strict_ppl::internal::concurrent_queue_base_v3< T >::my_rep, my_rep, and tbb::internal::swap().

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

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

## internal_throw_exception()

void tbb::internal::concurrent_queue_base_v3::internal_throw_exception | ( |  | ) | const

protected

throw an exception

Definition at line 547 of file concurrent_queue.cpp.

{
throw_exception( eid_bad_alloc );
}
tbb::internal::eid_bad_alloc
@ eid_bad_alloc
Definition: tbb_exception.h:68

References tbb::internal::eid_bad_alloc, and tbb::internal::throw_exception().

Here is the call graph for this function:

## Friends And Related Function Documentation

## concurrent_queue_iterator_base_v3

friend class concurrent_queue_iterator_base_v3

friend

Definition at line 835 of file _concurrent_queue_impl.h.

## concurrent_queue_iterator_rep

friend class concurrent_queue_iterator_rep

friend

Definition at line 834 of file _concurrent_queue_impl.h.

## concurrent_queue_rep

friend class concurrent_queue_rep

friend

Definition at line 831 of file _concurrent_queue_impl.h.

## micro_queue

friend struct micro_queue

friend

Definition at line 832 of file _concurrent_queue_impl.h.

## micro_queue_pop_finalizer

friend class micro_queue_pop_finalizer

friend

Definition at line 833 of file _concurrent_queue_impl.h.

## Member Data Documentation

## item_size

size_t tbb::internal::concurrent_queue_base_v3::item_size

protected

Size of an item.

Definition at line 850 of file _concurrent_queue_impl.h.

Referenced by concurrent_queue_base_v3(), tbb::internal::concurrent_queue_iterator_rep::get_item(), and internal_swap().

## items_per_page

size_t tbb::internal::concurrent_queue_base_v3::items_per_page

protected

Always a power of 2.

Definition at line 847 of file _concurrent_queue_impl.h.

Referenced by tbb::internal::concurrent_queue_iterator_base_v3::advance(), tbb::concurrent_bounded_queue< T, A >::allocate_page(), tbb::internal::micro_queue::assign(), concurrent_queue_base_v3(), tbb::concurrent_bounded_queue< T, A >::deallocate_page(), tbb::internal::concurrent_queue_iterator_rep::get_item(), tbb::concurrent_bounded_queue< T, A >::get_ref(), internal_assign(), internal_swap(), tbb::internal::micro_queue::pop(), and tbb::internal::micro_queue::push().

## my_capacity

ptrdiff_t tbb::internal::concurrent_queue_base_v3::my_capacity

protected

Capacity of the queue.

Definition at line 844 of file _concurrent_queue_impl.h.

Referenced by tbb::concurrent_bounded_queue< T, A >::capacity(), concurrent_queue_base_v3(), internal_assign(), internal_insert_if_not_full(), internal_insert_item(), internal_set_capacity(), and internal_swap().

## my_rep

concurrent_queue_rep* tbb::internal::concurrent_queue_base_v3::my_rep

private

Internal representation.

Definition at line 829 of file _concurrent_queue_impl.h.

Referenced by concurrent_queue_base_v3(), tbb::internal::concurrent_queue_iterator_rep::concurrent_queue_iterator_rep(), tbb::internal::concurrent_queue_iterator_rep::get_item(), internal_abort(), internal_assign(), internal_empty(), internal_finish_clear(), internal_insert_if_not_full(), internal_insert_item(), internal_pop(), internal_pop_if_present(), internal_size(), internal_swap(), tbb::internal::micro_queue::pop(), tbb::internal::micro_queue::push(), and ~concurrent_queue_base_v3().

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

- _concurrent_queue_impl.h
- concurrent_queue.cpp

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.