void arena::close_arena () { #if !__TBB_STATISTICS_EARLY_DUMP GATHER_STATISTIC( dump_arena_statistics() ); #endif my_market->detach_arena( *this ); free_arena(); }
void arena::close_arena () { #if !__TBB_STATISTICS_EARLY_DUMP GATHER_STATISTIC( dump_arena_statistics() ); #endif my_market->detach_arena( *this ); __TBB_ASSERT( is_alive(my_guard), NULL ); free_arena(); }
void arena::free_arena () { __TBB_ASSERT( is_alive(my_guard), NULL ); __TBB_ASSERT( !my_num_threads_active, "There are threads in the dying arena" ); __TBB_ASSERT( !my_num_workers_requested && !my_num_workers_allotted, "Dying arena requests workers" ); __TBB_ASSERT( my_pool_state == SNAPSHOT_EMPTY || !my_max_num_workers, "Inconsistent state of a dying arena" ); #if !__TBB_STATISTICS_EARLY_DUMP GATHER_STATISTIC( dump_arena_statistics() ); #endif poison_value( my_guard ); intptr_t drained = 0; for ( unsigned i = 1; i <= my_num_slots; ++i ) drained += mailbox(i).drain(); #if __TBB_TASK_PRIORITY && TBB_USE_ASSERT for ( intptr_t i = 0; i < num_priority_levels; ++i ) __TBB_ASSERT(my_task_stream[i].empty() && my_task_stream[i].drain()==0, "Not all enqueued tasks were executed"); #elif !__TBB_TASK_PRIORITY __TBB_ASSERT(my_task_stream.empty() && my_task_stream.drain()==0, "Not all enqueued tasks were executed"); #endif /* !__TBB_TASK_PRIORITY */ #if __TBB_COUNT_TASK_NODES my_market->update_task_node_count( -drained ); #endif /* __TBB_COUNT_TASK_NODES */ my_market->release(); #if __TBB_TASK_GROUP_CONTEXT __TBB_ASSERT( my_master_default_ctx, "Master thread never entered the arena?" ); my_master_default_ctx->~task_group_context(); NFS_Free(my_master_default_ctx); #endif /* __TBB_TASK_GROUP_CONTEXT */ #if __TBB_STATISTICS for( unsigned i = 0; i < my_num_slots; ++i ) NFS_Free( my_slots[i].my_counters ); #endif /* __TBB_STATISTICS */ void* storage = &mailbox(my_num_slots); __TBB_ASSERT( my_num_threads_active == 0, NULL ); __TBB_ASSERT( my_pool_state == SNAPSHOT_EMPTY || !my_max_num_workers, NULL ); this->~arena(); #if TBB_USE_ASSERT > 1 memset( storage, 0, allocation_size(my_max_num_workers) ); #endif /* TBB_USE_ASSERT */ NFS_Free( storage ); }