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 #include "limits.h"
00026
00027 namespace tbb {
00028
00029 typedef std::size_t stack_size_type;
00030
00032 namespace internal {
00034
00035 class scheduler;
00036 }
00038
00040
00053 class task_scheduler_init: internal::no_copy {
00054 enum ExceptionPropagationMode {
00055 propagation_mode_exact = 1u,
00056 propagation_mode_captured = 2u,
00057 propagation_mode_mask = propagation_mode_exact | propagation_mode_captured
00058 };
00059
00061 internal::scheduler* my_scheduler;
00062 public:
00063
00065 static const int automatic = -1;
00066
00068 static const int deferred = -2;
00069
00071
00082 void __TBB_EXPORTED_METHOD initialize( int number_of_threads=automatic );
00083
00085
00086 void __TBB_EXPORTED_METHOD initialize( int number_of_threads, stack_size_type thread_stack_size );
00087
00089 void __TBB_EXPORTED_METHOD terminate();
00090
00092 task_scheduler_init( int number_of_threads=automatic, stack_size_type thread_stack_size=0 ) : my_scheduler(NULL) {
00093
00094
00095
00096
00097
00098
00099
00100 __TBB_ASSERT( !(thread_stack_size & propagation_mode_mask), "Requested stack size is not aligned" );
00101 #if TBB_USE_EXCEPTIONS
00102 thread_stack_size |= TBB_USE_CAPTURED_EXCEPTION ? propagation_mode_captured : propagation_mode_exact;
00103 #endif
00104 initialize( number_of_threads, thread_stack_size );
00105 }
00106
00108 ~task_scheduler_init() {
00109 if( my_scheduler )
00110 terminate();
00111 internal::poison_pointer( my_scheduler );
00112 }
00114
00131 static int __TBB_EXPORTED_FUNC default_num_threads ();
00132
00134 bool is_active() const { return my_scheduler != NULL; }
00135 };
00136
00137 }
00138
00139 #endif