Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
Go to the documentation of this file.
17 #ifndef __TBB_task_arena_H
18 #define __TBB_task_arena_H
20 #define __TBB_task_arena_H_include_area
26 #if __TBB_NUMA_SUPPORT
29 #if TBB_USE_THREADING_TOOLS
36 namespace this_task_arena {
49 namespace interface7 {
58 virtual void operator()()
const = 0;
66 #if __TBB_CPP11_DECLTYPE_PRESENT && !__TBB_CPP11_DECLTYPE_OF_FUNCTION_RETURN_TYPE_BROKEN
67 typedef decltype(declval<F>()())
type;
73 template<
typename F,
typename R>
79 new (my_return_storage.begin()) R(my_func());
88 my_return_storage.begin()->~R();
106 #if __TBB_NUMA_SUPPORT
110 constraints(numa_node_id
id = automatic,
int maximal_concurrency = automatic)
114 numa_node_id numa_id;
122 #if __TBB_TASK_GROUP_CONTEXT
138 #if __TBB_NUMA_SUPPORT
139 numa_node_id my_numa_id;
147 numa_node_id numa_id() {
148 return (my_version_and_traits & numa_support_flag) == numa_support_flag ? my_numa_id : automatic;
154 #if __TBB_TASK_GROUP_CONTEXT
158 #
if __TBB_NUMA_SUPPORT
159 , numa_support_flag = 1
169 , my_master_slots(reserved_for_masters)
170 #if __TBB_NUMA_SUPPORT
171 , my_version_and_traits(default_flags | numa_support_flag)
173 , my_version_and_traits(default_flags)
175 , my_initialized(false)
176 #if __TBB_NUMA_SUPPORT
177 , my_numa_id(automatic)
181 #if __TBB_NUMA_SUPPORT
182 task_arena_base(
const constraints& constraints_,
unsigned reserved_for_masters)
188 , my_master_slots(reserved_for_masters)
189 , my_version_and_traits(default_flags | numa_support_flag)
190 , my_initialized(false)
191 , my_numa_id(constraints_.numa_id )
205 static const int automatic = -1;
206 static const int not_initialized = -2;
210 #if __TBB_TASK_ISOLATION
213 template<
typename R,
typename F>
217 return d.consume_result();
237 __TBB_ASSERT( my_arena,
"task_arena initialization is incomplete" );
238 #if __TBB_TASK_GROUP_CONTEXT
239 __TBB_ASSERT( my_context,
"task_arena initialization is incomplete" );
241 #if TBB_USE_THREADING_TOOLS
246 my_initialized =
true;
256 #if !__TBB_TASK_PRIORITY
260 #if __TBB_TASK_GROUP_CONTEXT
267 template<
typename R,
typename F>
272 return d.consume_result();
282 task_arena(
int max_concurrency_ = automatic,
unsigned reserved_for_masters = 1)
286 #if __TBB_NUMA_SUPPORT
287 task_arena(
const constraints& constraints_,
unsigned reserved_for_masters = 1)
297 task_arena(
const task_arena &
s)
299 : task_arena_base(
s.my_max_concurrency,
s.my_master_slots)
311 if( my_arena ) my_initialized =
true;
316 if( !my_initialized ) {
317 internal_initialize();
323 inline void initialize(
int max_concurrency_,
unsigned reserved_for_masters = 1) {
325 __TBB_ASSERT(!my_arena,
"Impossible to modify settings of an already initialized task_arena");
326 if( !my_initialized ) {
327 my_max_concurrency = max_concurrency_;
328 my_master_slots = reserved_for_masters;
333 #if __TBB_NUMA_SUPPORT
334 inline void initialize(constraints constraints_,
unsigned reserved_for_masters = 1) {
336 __TBB_ASSERT(!my_arena,
"Impossible to modify settings of an already initialized task_arena");
337 if( !my_initialized ) {
338 my_numa_id = constraints_.numa_id;
339 my_max_concurrency = constraints_.max_concurrency;
340 my_master_slots = reserved_for_masters;
349 __TBB_ASSERT(!my_arena,
"Impossible to modify settings of an already initialized task_arena");
350 if( !my_initialized ) {
352 if ( !my_arena ) internal_initialize();
360 if( my_initialized ) {
361 internal_terminate();
362 my_initialized =
false;
379 #if __TBB_CPP11_RVALUE_REF_PRESENT
382 enqueue_impl(std::forward<F>(f));
386 void enqueue(
const F& f ) {
391 #if __TBB_TASK_PRIORITY
395 #if __TBB_CPP11_RVALUE_REF_PRESENT
397 #if __TBB_PREVIEW_CRITICAL_TASKS
403 enqueue_impl(std::forward<F>(f),
p);
407 #if __TBB_PREVIEW_CRITICAL_TASKS
416 #endif// __TBB_TASK_PRIORITY
436 #if __TBB_EXTRA_DEBUG
437 void debug_wait_until_empty() {
444 #endif //__TBB_EXTRA_DEBUG
449 return internal_current_slot();
455 return (my_max_concurrency>1) ? my_max_concurrency : internal_max_concurrency(
this);
459 namespace this_task_arena {
460 #if __TBB_TASK_ISOLATION
478 using interface7::task_arena;
480 namespace this_task_arena {
481 using namespace interface7::this_task_arena;
496 #if __TBB_TASK_PRIORITY
504 arena.internal_enqueue(t,
p);
509 #undef __TBB_task_arena_H_include_area
static void enqueue(task &t)
Enqueue task for starvation-resistant execution.
Used to form groups of tasks.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
intptr_t my_version_and_traits
Special settings.
#define __TBB_FORWARDING_REF(A)
internal::return_type_or_void< F >::type execute(F &f)
Base class for types that should not be assigned.
task_arena(int max_concurrency_=automatic, unsigned reserved_for_masters=1)
Creates task_arena with certain concurrency limits.
void initialize()
Forces allocation of the resources for the task_arena as specified in constructor arguments.
#define __TBB_TASK_GROUP_CONTEXT
static const int priority_critical
tbb::aligned_space< R > my_return_storage
Base class for user-defined tasks.
internal::return_type_or_void< F >::type execute(const F &f)
void __TBB_EXPORTED_FUNC isolate_within_arena(delegate_base &d, intptr_t isolation=0)
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
void consume_result() const
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
internal::return_type_or_void< F >::type isolate(const F &f)
unsigned my_master_slots
Reserved master slots.
int my_max_concurrency
Concurrency level for deferred initialization.
int max_concurrency() const
Returns the maximal number of threads that can work inside the arena.
task_arena_base(int max_concurrency, unsigned reserved_for_masters)
static int __TBB_EXPORTED_FUNC internal_max_concurrency(const task_arena *)
void move(tbb_thread &t1, tbb_thread &t2)
int current_thread_index()
Returns the index, aka slot number, of the calling thread in its current arena.
int max_concurrency()
Returns the maximal number of threads that can work inside the arena.
void initialize(attach)
Attaches this instance to the current arena of the thread.
void const char const char int ITT_FORMAT __itt_group_sync s
#define __TBB_EXPORTED_FUNC
#define __TBB_TASK_PRIORITY
Tag class used to indicate the "attaching" constructor.
void operator()() const __TBB_override
void enqueue_impl(__TBB_FORWARDING_REF(F) f, priority_t p=priority_t(0))
atomic< T > & as_atomic(T &t)
task_arena(attach)
Creates an instance of task_arena attached to the current arena of the thread.
static int current_thread_index()
void initialize(int max_concurrency_, unsigned reserved_for_masters=1)
Overrides concurrency level and forces initialization of internal representation.
Identifiers declared inside namespace internal should never be used directly by client code.
void const char const char int ITT_FORMAT __itt_group_sync p
#define __TBB_EXPORTED_METHOD
__TBB_DEPRECATED void enqueue(F &&f, priority_t p)
static const int not_initialized
void operator()() const __TBB_override
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_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
internal::arena * my_arena
NULL if not currently initialized.
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.