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

Method nested_arena_entry

benchmarks/tbb/arena.cpp:548–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546};
547
548void generic_scheduler::nested_arena_entry(arena* a, nested_arena_context& c, bool as_worker) {
549 if( a == my_arena ) {
550#if __TBB_TASK_GROUP_CONTEXT
551 c.my_orig_ptr = my_innermost_running_task =
552 new(&allocate_task(sizeof(empty_task), NULL, a->my_default_ctx)) empty_task;
553#endif
554 return;
555 }
556 __TBB_ASSERT( is_alive(a->my_guard), NULL );
557 // overwrite arena settings
558#if __TBB_TASK_PRIORITY
559 if ( my_offloaded_tasks )
560 my_arena->orphan_offloaded_tasks( *this );
561 my_ref_top_priority = &a->my_top_priority;
562 my_ref_reload_epoch = &a->my_reload_epoch;
563 my_local_reload_epoch = a->my_reload_epoch;
564#endif /* __TBB_TASK_PRIORITY */
565 my_arena = a;
566 my_arena_index = 0;
567 my_arena_slot = my_arena->my_slots + my_arena_index;
568 my_inbox.detach(); // TODO: mailboxes were not designed for switching, add copy constructor?
569 attach_mailbox( affinity_id(my_arena_index+1) );
570 my_innermost_running_task = my_dispatching_task = as_worker? NULL : my_dummy_task;
571#if __TBB_TASK_GROUP_CONTEXT
572 // save dummy's context and replace it by arena's context
573 c.my_orig_ptr = my_dummy_task->prefix().context;
574 my_dummy_task->prefix().context = a->my_default_ctx;
575#endif
576#if __TBB_ARENA_OBSERVER
577 my_last_local_observer = 0; // TODO: try optimize number of calls
578 my_arena->my_observers.notify_entry_observers( my_last_local_observer, /*worker=*/false );
579#endif
580 // TODO? ITT_NOTIFY(sync_acquired, a->my_slots + index);
581 // TODO: it requires market to have P workers (not P-1)
582 // TODO: it still allows temporary oversubscription by 1 worker (due to my_max_num_workers)
583 // TODO: a preempted worker should be excluded from assignment to other arenas e.g. my_slack--
584 if( c.my_adjusting ) my_arena->my_market->adjust_demand(*my_arena, -1);
585}
586
587void generic_scheduler::nested_arena_exit(nested_arena_context& c) {
588 if( my_arena == c.my_orig_state.my_arena ) {

Callers 1

nested_arena_contextMethod · 0.80

Calls 5

is_aliveFunction · 0.85
adjust_demandMethod · 0.80
detachMethod · 0.45

Tested by

no test coverage detected