00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __TBB_task_scheduler_init_H
00022 #define __TBB_task_scheduler_init_H
00023
00024 #include "tbb_stddef.h"
00025
00026 namespace tbb {
00027
00028 typedef std::size_t stack_size_type;
00029
00031 namespace internal {
00033
00034 class scheduler;
00035 }
00037
00039
00042 class task_scheduler_init: internal::no_copy {
00044 internal::scheduler* my_scheduler;
00045 public:
00046
00048 static const int automatic = -1;
00049
00051 static const int deferred = -2;
00052
00054
00062 void __TBB_EXPORTED_METHOD initialize( int number_of_threads=automatic );
00063
00065
00066 void __TBB_EXPORTED_METHOD initialize( int number_of_threads, stack_size_type thread_stack_size );
00067
00069 void __TBB_EXPORTED_METHOD terminate();
00070
00072 task_scheduler_init( int number_of_threads=automatic, stack_size_type thread_stack_size=0 ) : my_scheduler(NULL) {
00073 initialize( number_of_threads, thread_stack_size );
00074 }
00075
00077 ~task_scheduler_init() {
00078 if( my_scheduler )
00079 terminate();
00080 internal::poison_pointer( my_scheduler );
00081 }
00083
00090 static int __TBB_EXPORTED_FUNC default_num_threads ();
00091
00093 bool is_active() const { return my_scheduler != NULL; }
00094 };
00095
00096 }
00097
00098 #endif