17 #ifndef __TBB_task_arena_H 18 #define __TBB_task_arena_H 20 #define __TBB_task_arena_H_include_area 26 #if TBB_USE_THREADING_TOOLS 33 namespace this_task_arena {
46 namespace interface7 {
55 virtual void operator()()
const = 0;
63 #if __TBB_CPP11_DECLTYPE_PRESENT && !__TBB_CPP11_DECLTYPE_OF_FUNCTION_RETURN_TYPE_BROKEN 64 typedef decltype(declval<F>()())
type;
70 template<
typename F,
typename R>
76 new (my_return_storage.begin()) R(my_func());
85 my_return_storage.begin()->~R();
107 #if __TBB_TASK_GROUP_CONTEXT 123 #if __TBB_TASK_GROUP_CONTEXT 134 , my_max_concurrency(max_concurrency)
135 , my_master_slots(reserved_for_masters)
136 , my_version_and_traits(default_flags)
149 static const int automatic = -1;
150 static const int not_initialized = -2;
154 #if __TBB_TASK_ISOLATION 157 template<
typename R,
typename F>
182 __TBB_ASSERT( my_arena,
"task_arena initialization is incomplete" );
183 #if __TBB_TASK_GROUP_CONTEXT 184 __TBB_ASSERT( my_context,
"task_arena initialization is incomplete" );
186 #if TBB_USE_THREADING_TOOLS 191 my_initialized =
true;
201 #if !__TBB_TASK_PRIORITY 205 #if __TBB_TASK_GROUP_CONTEXT 212 template<
typename R,
typename F>
227 task_arena(
int max_concurrency_ = automatic,
unsigned reserved_for_masters = 1)
229 , my_initialized(false)
235 , my_initialized(false)
244 , my_initialized(false)
247 if( my_arena ) my_initialized =
true;
252 if( !my_initialized ) {
253 internal_initialize();
259 inline void initialize(
int max_concurrency_,
unsigned reserved_for_masters = 1) {
261 __TBB_ASSERT(!my_arena,
"Impossible to modify settings of an already initialized task_arena");
262 if( !my_initialized ) {
263 my_max_concurrency = max_concurrency_;
264 my_master_slots = reserved_for_masters;
272 __TBB_ASSERT(!my_arena,
"Impossible to modify settings of an already initialized task_arena");
273 if( !my_initialized ) {
275 if ( !my_arena ) internal_initialize();
283 if( my_initialized ) {
284 internal_terminate();
285 my_initialized =
false;
302 #if __TBB_CPP11_RVALUE_REF_PRESENT 305 enqueue_impl(std::forward<F>(f));
309 void enqueue(
const F& f ) {
314 #if __TBB_TASK_PRIORITY 318 #if __TBB_CPP11_RVALUE_REF_PRESENT 320 #if __TBB_PREVIEW_CRITICAL_TASKS 326 enqueue_impl(std::forward<F>(f), p);
330 #if __TBB_PREVIEW_CRITICAL_TASKS 339 #endif// __TBB_TASK_PRIORITY 359 #if __TBB_EXTRA_DEBUG 360 void debug_wait_until_empty() {
367 #endif //__TBB_EXTRA_DEBUG 372 return internal_current_slot();
378 return (my_max_concurrency>1) ? my_max_concurrency : internal_max_concurrency(
this);
382 namespace this_task_arena {
383 #if __TBB_TASK_ISOLATION 403 namespace this_task_arena {
404 using namespace interface7::this_task_arena;
419 #if __TBB_TASK_PRIORITY 432 #undef __TBB_task_arena_H_include_area task_arena_base(int max_concurrency, unsigned reserved_for_masters)
void move(tbb_thread &t1, tbb_thread &t2)
Base class for user-defined tasks.
int max_concurrency() const
Returns the maximal number of threads that can work inside the arena.
tbb::aligned_space< R > my_return_storage
static int current_thread_index()
void const char const char int ITT_FORMAT __itt_group_sync s
internal::arena * my_arena
NULL if not currently initialized.
int max_concurrency()
Returns the maximal number of threads that can work inside the arena.
void __TBB_EXPORTED_FUNC isolate_within_arena(delegate_base &d, intptr_t isolation=0)
#define __TBB_TASK_PRIORITY
Base class for types that should not be assigned.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
int current_thread_index()
Returns the index, aka slot number, of the calling thread in its current arena.
#define __TBB_FORWARDING_REF(A)
intptr_t my_version_and_traits
Special settings.
void consume_result() const
int my_max_concurrency
Concurrency level for deferred initialization.
void enqueue_impl(__TBB_FORWARDING_REF(F) f, priority_t p=priority_t(0))
atomic< T > & as_atomic(T &t)
static const int priority_critical
void operator()() const __TBB_override
Used to form groups of tasks.
task_arena(int max_concurrency_=automatic, unsigned reserved_for_masters=1)
Creates task_arena with certain concurrency limits.
void initialize(int max_concurrency_, unsigned reserved_for_masters=1)
Overrides concurrency level and forces initialization of internal representation. ...
unsigned my_master_slots
Reserved master slots.
void initialize()
Forces allocation of the resources for the task_arena as specified in constructor arguments...
#define __TBB_EXPORTED_METHOD
Identifiers declared inside namespace internal should never be used directly by client code...
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
task_arena(const task_arena &s)
Copies settings from another task_arena.
__TBB_DEPRECATED void enqueue(F &&f, priority_t p)
#define __TBB_TASK_GROUP_CONTEXT
void __TBB_EXPORTED_METHOD internal_enqueue(task &, intptr_t) const
static int __TBB_EXPORTED_FUNC internal_max_concurrency(const task_arena *)
void const char const char int ITT_FORMAT __itt_group_sync p
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
static void enqueue(task &t)
Enqueue task for starvation-resistant execution.
Tag class used to indicate the "attaching" constructor.
internal::return_type_or_void< F >::type isolate(const F &f)
task_arena(attach)
Creates an instance of task_arena attached to the current arena of the thread.
void operator()() const __TBB_override
internal::return_type_or_void< F >::type execute(const F &f)
internal::return_type_or_void< F >::type execute(F &f)
void initialize(attach)
Attaches this instance to the current arena of the thread.
#define __TBB_EXPORTED_FUNC
static const int not_initialized