task_scheduler_init.h
Go to the documentation of this file.
/*
Copyright (c) 2005-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "internal/_deprecated_header_message_guard.h"
#if !defined(__TBB_show_deprecation_message_task_scheduler_init_H) && defined(__TBB_show_deprecated_header_message)
#define __TBB_show_deprecation_message_task_scheduler_init_H
#pragma message("TBB Warning: tbb/task_scheduler_init.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.")
#endif
#if defined(__TBB_show_deprecated_header_message)
#undef __TBB_show_deprecated_header_message
#endif
#ifndef __TBB_task_scheduler_init_H
#define __TBB_task_scheduler_init_H
#define __TBB_task_scheduler_init_H_include_area
#include "internal/_warning_suppress_enable_notice.h"
#include "tbb_stddef.h"
#include "limits.h"
#if __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE
#include <new> // nothrow_t
#endif
namespace tbb {
typedef std::size_t stack_size_type;
namespace internal {
class scheduler;
} // namespace internal
class __TBB_DEPRECATED_VERBOSE task_scheduler_init: internal::no_copy {
enum ExceptionPropagationMode {
propagation_mode_exact = 1u,
propagation_mode_captured = 2u,
propagation_mode_mask = propagation_mode_exact | propagation_mode_captured
};
internal::scheduler* my_scheduler;
bool internal_terminate( bool blocking );
#if __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE
bool __TBB_EXPORTED_METHOD internal_blocking_terminate( bool throwing );
#endif
public:
static const int automatic = -1;
static const int deferred = -2;
void __TBB_EXPORTED_METHOD initialize( int number_of_threads=automatic );
void __TBB_EXPORTED_METHOD initialize( int number_of_threads, stack_size_type thread_stack_size );
void __TBB_EXPORTED_METHOD terminate();
#if __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE
#if TBB_USE_EXCEPTIONS
void blocking_terminate() {
internal_blocking_terminate( /*throwing=*/true );
}
#endif
bool blocking_terminate(const std::nothrow_t&) __TBB_NOEXCEPT(true) {
return internal_blocking_terminate( /*throwing=*/false );
}
#endif // __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE
task_scheduler_init( int number_of_threads=automatic, stack_size_type thread_stack_size=0 ) : my_scheduler(NULL)
{
// Two lowest order bits of the stack size argument may be taken to communicate
// default exception propagation mode of the client to be used when the
// client manually creates tasks in the master thread and does not use
// explicit task group context object. This is necessary because newer
// TBB binaries with exact propagation enabled by default may be used
// by older clients that expect tbb::captured_exception wrapper.
// All zeros mean old client - no preference.
__TBB_ASSERT( !(thread_stack_size & propagation_mode_mask), "Requested stack size is not aligned" );
#if TBB_USE_EXCEPTIONS
thread_stack_size |= TBB_USE_CAPTURED_EXCEPTION ? propagation_mode_captured : propagation_mode_exact;
#endif /* TBB_USE_EXCEPTIONS */
initialize( number_of_threads, thread_stack_size );
}
~task_scheduler_init() {
if( my_scheduler )
terminate();
internal::poison_pointer( my_scheduler );
}
static int __TBB_EXPORTED_FUNC default_num_threads ();
bool is_active() const { return my_scheduler != NULL; }
};
} // namespace tbb
#include "internal/_warning_suppress_disable_notice.h"
#undef __TBB_task_scheduler_init_H_include_area
#endif /* __TBB_task_scheduler_init_H */
_deprecated_header_message_guard.h
tbb::task_scheduler_init::~task_scheduler_init
~task_scheduler_init()
Destroy scheduler for this thread if thread has no other live task_scheduler_inits.
Definition: task_scheduler_init.h:140
internal
Definition: _flow_graph_async_msg_impl.h:24
TBB_USE_CAPTURED_EXCEPTION
#define TBB_USE_CAPTURED_EXCEPTION
Definition: tbb_config.h:493
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::no_copy
Base class for types that should not be copied or assigned.
Definition: tbb_stddef.h:330
tbb::task_scheduler_init::task_scheduler_init
task_scheduler_init(int number_of_threads=automatic, stack_size_type thread_stack_size=0)
Shorthand for default constructor followed by call to initialize(number_of_threads).
Definition: task_scheduler_init.h:123
tbb::task_scheduler_init
Class delimiting the scope of task scheduler activity.
Definition: task_scheduler_init.h:66
tbb::internal::poison_pointer
void poison_pointer(T *__TBB_atomic &)
Definition: tbb_stddef.h:305
tbb::task_scheduler_init::is_active
bool is_active() const
Returns true if scheduler is active (initialized); false otherwise.
Definition: task_scheduler_init.h:166
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
tbb::internal::scheduler
Definition: task.h:99
tbb::task_scheduler_init::ExceptionPropagationMode
ExceptionPropagationMode
Definition: task_scheduler_init.h:67
tbb::stack_size_type
std::size_t stack_size_type
Definition: task_scheduler_init.h:42
_warning_suppress_disable_notice.h
__TBB_EXPORTED_FUNC
#define __TBB_EXPORTED_FUNC
Definition: scalable_allocator.h:38
__TBB_NOEXCEPT
#define __TBB_NOEXCEPT(expression)
Definition: tbb_stddef.h:110
__TBB_DEPRECATED_VERBOSE
#define __TBB_DEPRECATED_VERBOSE
Definition: tbb_config.h:648
tbb_stddef.h
_warning_suppress_enable_notice.h
__TBB_EXPORTED_METHOD
#define __TBB_EXPORTED_METHOD
Definition: tbb_stddef.h:98
tbb::task_scheduler_init::my_scheduler
internal::scheduler * my_scheduler
Definition: task_scheduler_init.h:74

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

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.