void interface5::internal::task_base::destroy( task& victim ) { __TBB_ASSERT( victim.prefix().ref_count== (ConcurrentWaitsEnabled(victim) ? 1 : 0), "Task being destroyed must not have children" ); __TBB_ASSERT( victim.state()==task::allocated, "illegal state for victim task" ); task* parent = victim.parent(); victim.~task(); if( parent ) { __TBB_ASSERT( parent->state()==task::allocated, "attempt to destroy child of running or corrupted parent?" ); parent->internal_decrement_ref_count(); // Despite last reference to *parent removed, it should not be destroyed (documented behavior). } governor::local_scheduler()->free_task<no_hint>( victim ); }
void interface5::internal::task_base::destroy( task& victim ) { // 1 may be a guard reference for wait_for_all, which was not reset because // of concurrent_wait mode or because prepared root task was not actually used // for spawning tasks (as in structured_task_group). __TBB_ASSERT( (intptr_t)victim.prefix().ref_count <= 1, "Task being destroyed must not have children" ); __TBB_ASSERT( victim.state()==task::allocated, "illegal state for victim task" ); task* parent = victim.parent(); victim.~task(); if( parent ) { __TBB_ASSERT( parent->state()==task::allocated, "attempt to destroy child of running or corrupted parent?" ); parent->internal_decrement_ref_count(); // Even if the last reference to *parent is removed, it should not be spawned (documented behavior). } governor::local_scheduler()->free_task<no_hint>( victim ); }