MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / internal_insert_item

Method internal_insert_item

benchmarks/tbb/concurrent_queue.cpp:384–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382}
383
384void concurrent_queue_base_v3::internal_insert_item( const void* src, copy_specifics op_type ) {
385 concurrent_queue_rep& r = *my_rep;
386 ticket k = r.tail_counter++;
387 ptrdiff_t e = my_capacity;
388#if DO_ITT_NOTIFY
389 bool sync_prepare_done = false;
390#endif
391 if( (ptrdiff_t)(k-r.head_counter)>=e ) { // queue is full
392#if DO_ITT_NOTIFY
393 if( !sync_prepare_done ) {
394 ITT_NOTIFY( sync_prepare, &sync_prepare_done );
395 sync_prepare_done = true;
396 }
397#endif
398 bool slept = false;
399 concurrent_monitor::thread_context thr_ctx;
400 r.slots_avail.prepare_wait( thr_ctx, ((ptrdiff_t)(k-e)) );
401 while( (ptrdiff_t)(k-r.head_counter)>=const_cast<volatile ptrdiff_t&>(e = my_capacity) ) {
402 __TBB_TRY {
403 slept = r.slots_avail.commit_wait( thr_ctx );
404 } __TBB_CATCH( tbb::user_abort& ) {
405 r.choose(k).abort_push(k, *this);
406 __TBB_RETHROW();
407 } __TBB_CATCH(...) {
408 __TBB_RETHROW();
409 }
410 if (slept == true) break;
411 r.slots_avail.prepare_wait( thr_ctx, ((ptrdiff_t)(k-e)) );
412 }
413 if( !slept )
414 r.slots_avail.cancel_wait( thr_ctx );
415 }
416 ITT_NOTIFY( sync_acquired, &sync_prepare_done );
417 __TBB_ASSERT( (ptrdiff_t)(k-r.head_counter)<my_capacity, NULL);
418 r.choose( k ).push( src, k, *this, op_type );

Callers

nothing calls this directly

Calls 3

prepare_waitMethod · 0.45
commit_waitMethod · 0.45
cancel_waitMethod · 0.45

Tested by

no test coverage detected