21 #ifndef __TBB_task_arena_H 22 #define __TBB_task_arena_H 27 #if TBB_USE_THREADING_TOOLS 34 namespace this_task_arena {
47 namespace interface7 {
56 virtual void operator()()
const = 0;
64 #if __TBB_CPP11_DECLTYPE_PRESENT && !__TBB_CPP11_DECLTYPE_OF_FUNCTION_RETURN_TYPE_BROKEN 65 typedef decltype(declval<F>()())
type;
71 template<
typename F,
typename R>
77 new (my_return_storage.
begin()) R(my_func());
86 my_return_storage.
begin()->~R();
108 #if __TBB_TASK_GROUP_CONTEXT 124 #if __TBB_TASK_GROUP_CONTEXT 136 , my_master_slots(reserved_for_masters)
137 , my_version_and_traits(default_flags)
150 static const int automatic = -1;
151 static const int not_initialized = -2;
155 #if __TBB_TASK_ISOLATION 158 template<
typename R,
typename F>
162 return d.consume_result();
178 __TBB_ASSERT( my_arena,
"task_arena initialization is incomplete" );
179 #if __TBB_TASK_GROUP_CONTEXT 180 __TBB_ASSERT( my_context,
"task_arena initialization is incomplete" );
182 #if TBB_USE_THREADING_TOOLS 187 my_initialized =
true;
197 #if !__TBB_TASK_PRIORITY 201 #if __TBB_TASK_GROUP_CONTEXT 208 template<
typename R,
typename F>
211 internal::delegated_function<F, R>
d(f);
213 return d.consume_result();
223 task_arena(
int max_concurrency_ = automatic,
unsigned reserved_for_masters = 1)
225 , my_initialized(false)
231 , my_initialized(false)
240 , my_initialized(false)
243 if( my_arena ) my_initialized =
true;
248 if( !my_initialized ) {
249 internal_initialize();
255 inline void initialize(
int max_concurrency_,
unsigned reserved_for_masters = 1) {
257 __TBB_ASSERT(!my_arena,
"Impossible to modify settings of an already initialized task_arena");
258 if( !my_initialized ) {
259 my_max_concurrency = max_concurrency_;
260 my_master_slots = reserved_for_masters;
268 __TBB_ASSERT(!my_arena,
"Impossible to modify settings of an already initialized task_arena");
269 if( !my_initialized ) {
271 if ( !my_arena ) internal_initialize();
279 if( my_initialized ) {
280 internal_terminate();
281 my_initialized =
false;
298 #if __TBB_CPP11_RVALUE_REF_PRESENT 301 enqueue_impl(std::forward<F>(f));
305 void enqueue(
const F& f ) {
310 #if __TBB_TASK_PRIORITY 314 #if __TBB_CPP11_RVALUE_REF_PRESENT 316 #if __TBB_PREVIEW_CRITICAL_TASKS 322 enqueue_impl(std::forward<F>(f),
p);
326 #if __TBB_PREVIEW_CRITICAL_TASKS 335 #endif// __TBB_TASK_PRIORITY 355 #if __TBB_EXTRA_DEBUG 356 void debug_wait_until_empty() {
363 #endif //__TBB_EXTRA_DEBUG 368 return internal_current_slot();
374 return (my_max_concurrency>1) ? my_max_concurrency : internal_max_concurrency(
this);
378 #if __TBB_TASK_ISOLATION 379 namespace this_task_arena {
397 using interface7::task_arena;
398 #if __TBB_TASK_ISOLATION 399 namespace this_task_arena {
400 using namespace interface7::this_task_arena;
404 namespace this_task_arena {
Tag class used to indicate the "attaching" constructor.
internal::return_type_or_void< F >::type isolate(const F &f)
void consume_result() const
static int current_thread_index()
task_arena_base(int max_concurrency, unsigned reserved_for_masters)
T * begin() const
Pointer to beginning of array.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
void operator()() const __TBB_override
Used to form groups of tasks.
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
int max_concurrency() const
Returns the maximal number of threads that can work inside the arena.
decltype(declval< F >()()) typedef type
task_arena(const task_arena &s)
Copies settings from another task_arena.
internal::return_type_or_void< F >::type execute(F &f)
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
#define __TBB_TASK_PRIORITY
intptr_t my_version_and_traits
Special settings.
int my_max_concurrency
Concurrency level for deferred initialization.
Base class for user-defined tasks.
task_arena(attach)
Creates an instance of task_arena attached to the current arena of the thread.
void const char const char int ITT_FORMAT __itt_group_sync p
Base class for types that should not be assigned.
void enqueue_impl(__TBB_FORWARDING_REF(F) f, priority_t p=priority_t(0))
void initialize(int max_concurrency_, unsigned reserved_for_masters=1)
Overrides concurrency level and forces initialization of internal representation.
#define __TBB_EXPORTED_METHOD
int max_concurrency()
Returns the maximal number of threads that can work inside the arena.
#define __TBB_FORWARDING_REF(A)
internal::return_type_or_void< F >::type execute(const F &f)
void __TBB_EXPORTED_FUNC isolate_within_arena(delegate_base &d, intptr_t reserved=0)
task_arena(int max_concurrency_=automatic, unsigned reserved_for_masters=1)
Creates task_arena with certain concurrency limits.
unsigned my_master_slots
Reserved master slots.
#define __TBB_EXPORTED_FUNC
void move(tbb_thread &t1, tbb_thread &t2)
void enqueue(F &&f, priority_t p)
void const char const char int ITT_FORMAT __itt_group_sync s
void initialize(attach)
Attaches this instance to the current arena of the thread.
int current_thread_index()
Returns the index, aka slot number, of the calling thread in its current arena.
internal::arena * my_arena
NULL if not currently initialized.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
static int __TBB_EXPORTED_FUNC internal_max_concurrency(const task_arena *)
static const int priority_critical
Identifiers declared inside namespace internal should never be used directly by client code.
void initialize()
Forces allocation of the resources for the task_arena as specified in constructor arguments.
atomic< T > & as_atomic(T &t)
tbb::aligned_space< R > my_return_storage
static const int not_initialized
#define __TBB_TASK_GROUP_CONTEXT
void operator()() const __TBB_override