Intel Threading Building Blocks 2.1 for Open Source

Public Member Functions | Static Public Member Functions | Static Public Attributes

tbb::task_scheduler_init Class Reference
[Task Scheduling]

#include <task_scheduler_init.h>

Inheritance diagram for tbb::task_scheduler_init:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void initialize (int number_of_threads=automatic)
 Ensure that scheduler exists for this thread.
void initialize (int number_of_threads, stack_size_type thread_stack_size)
 The overloaded method with stack size parameter.
bool is_active () const
 Returns true if scheduler is active (initialized); false otherwise.
 task_scheduler_init (int number_of_threads=automatic, stack_size_type thread_stack_size=0)
 Shorthand for default constructor followed by call to intialize(number_of_threads).
void terminate ()
 Inverse of method initialize.
 ~task_scheduler_init ()
 Destroy scheduler for this thread if thread has no other live task_scheduler_inits.

Static Public Member Functions

static int default_num_threads ()
 Returns the number of threads tbb scheduler would create if initialized by default.

Static Public Attributes

static const int automatic = -1
 Typedef for number of threads that is automatic.
static const int deferred = -2
 Argument to initialize() or constructor that causes initialization to be deferred.

Detailed Description

Class representing reference to tbb scheduler. A thread must construct a task_scheduler_init, and keep it alive, during the time that it uses the services of class task.

Definition at line 50 of file task_scheduler_init.h.


Constructor & Destructor Documentation

tbb::task_scheduler_init::task_scheduler_init ( int  number_of_threads = automatic,
stack_size_type  thread_stack_size = 0 
) [inline]

Definition at line 80 of file task_scheduler_init.h.

References initialize().

                                                                                                : my_scheduler(NULL)  {
        initialize( number_of_threads, thread_stack_size );
    }

tbb::task_scheduler_init::~task_scheduler_init (  )  [inline]

Definition at line 85 of file task_scheduler_init.h.

References terminate().

                           {
        if( my_scheduler ) 
            terminate();
        internal::poison_pointer( my_scheduler );
    }


Member Function Documentation

static int tbb::task_scheduler_init::default_num_threads (  )  [static]

Result returned by this method does not depend on whether the scheduler has already been initialized.

Because tbb 2.0 does not support blocking tasks yet, you may use this method to boost the number of threads in the tbb's internal pool, if your tasks are doing I/O operations. The optimal number of additional threads depends on how much time your tasks spend in the blocked state.

Referenced by main().

void tbb::task_scheduler_init::initialize ( int  number_of_threads = automatic  ) 

A value of -1 lets tbb decide on the number of threads, which is typically the number of hardware threads. For production code, the default value of -1 should be used, particularly if the client code is mixed with third party clients that might also use tbb.

The number_of_threads is ignored if any other task_scheduler_inits currently exist. A thread may construct multiple task_scheduler_inits. Doing so does no harm because the underlying scheduler is reference counted.

Referenced by main(), and task_scheduler_init().

void tbb::task_scheduler_init::initialize ( int  number_of_threads,
stack_size_type  thread_stack_size 
)

Overloading is necessary to preserve ABI compatibility

bool tbb::task_scheduler_init::is_active (  )  const [inline]

Definition at line 101 of file task_scheduler_init.h.

{ return my_scheduler != NULL; }

void tbb::task_scheduler_init::terminate (  ) 

Member Data Documentation

const int tbb::task_scheduler_init::automatic = -1 [static]
const int tbb::task_scheduler_init::deferred = -2 [static]

Definition at line 59 of file task_scheduler_init.h.

Referenced by main().


The documentation for this class was generated from the following file:

Copyright © 2005-2010 Intel Corporation. All Rights Reserved.

Licensed under the GNU General Public License 2 with the runtime exception.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.