Keywords: ~task_scheduler_init

# ~task_scheduler_init()

Effects

If the `task_scheduler_init` is inactive, nothing happens. Otherwise, the `task_scheduler_init` is deactivated as follows. If the thread has no other active `task_scheduler_init` objects, the thread deallocates internal thread-specific resources required for scheduling `task` objects. If no existing thread has any active `task_scheduler_init` objects, then the internal worker threads are terminated.

## void initialize( int max_threads=automatic )

Requirements

The `task_scheduler_init` shall be inactive.

Effects

Similar to constructor.

## void terminate()

Requirements

The `task_scheduler_init` shall be active.

Effects

Deactivates the `task_scheduler_init` without destroying it. The description of the destructor specifies what deactivation entails.

## int default_num_threads()

Returns

One more than the number of worker threads that `task_scheduler_init` creates by default.

## bool is_active() const

Returns

True if `*this` is active as described in Section task_scheduler_init Class ; false otherwise.

## Mixing with OpenMP

Mixing OpenMP with Intel® Threading Building Blocks is supported. Performance may be less than a pure OpenMP or pure Intel® Threading Building Blocks solution if the two forms of parallelism are nested.

An OpenMP parallel region that plans to use the `task` scheduler should create a `task_scheduler_init` inside the parallel region, because the parallel region may create new threads unknown to Intel® Threading Building Blocks. Each of these new OpenMP threads, like native threads, must create a `task_scheduler_init` object before using Intel® Threading Building Blocks algorithms. The following example demonstrates how to do this.

    void OpenMP_Calls_TBB( int n ) {
    #pragma omp parallel
         {
             task_scheduler_init init;
    #pragma omp for
             for( int i=0; i<n; ++i ) {
                 ...can use class task or
                    Intel(R) Threading Building Blocks algorithms here ...
             }
         }
    }

Parent topic: task_scheduler_init Class

## See Also

task_scheduler_init int max_threads