This feature is deprecated and will be removed in the future.


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 )


The task_scheduler_init shall be inactive.


Similar to constructor.

void terminate()


The task_scheduler_init shall be active.


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

int default_num_threads()


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

bool is_active() const


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® Threading Building Blocks algorithms here ...
Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.