@@ -253,7 +253,12 @@ class task_arena_base {
253253public:
254254 // ! Typedef for number of threads that is automatic.
255255 static const int automatic = -1 ;
256+ // ! Typedef for current thread index in an uninitialized arena.
256257 static const int not_initialized = -2 ;
258+ #if __TBB_PREVIEW_TASK_ARENA_CORE_TYPE_SELECTOR
259+ // ! Typedef for core type(s) to be specified by the provided selector.
260+ static const int selectable = -2 ;
261+ #endif
257262};
258263
259264template <typename R, typename F>
@@ -364,6 +369,28 @@ class task_arena : public task_arena_base {
364369 )
365370 {}
366371
372+ #if __TBB_PREVIEW_TASK_ARENA_CORE_TYPE_SELECTOR
373+ // ! Creates task arena with a custom selector for core types
374+ template <typename Selector,
375+ typename = decltype (static_cast <int >(std::declval<Selector>()(std::declval<std::tuple<int , size_t , size_t >>())))>
376+ task_arena (const constraints& constraints_, Selector selector_,
377+ unsigned reserved_for_masters = 1 , priority a_priority = priority::normal
378+ #if __TBB_PREVIEW_PARALLEL_PHASE
379+ , leave_policy lp = leave_policy::automatic
380+ #endif
381+ )
382+ : task_arena_base(constraints_, reserved_for_masters, a_priority
383+ #if __TBB_PREVIEW_PARALLEL_PHASE
384+ , lp
385+ #endif
386+ )
387+ {
388+ if (my_core_type == selectable) {
389+ my_core_type = apply_core_type_selector (selector_);
390+ }
391+ }
392+ #endif
393+
367394 // ! Copies settings from another task_arena
368395 task_arena (const task_arena &a) // copy settings but not the reference or instance
369396 : task_arena_base(
@@ -440,6 +467,7 @@ class task_arena : public task_arena_base {
440467 }
441468
442469#if __TBB_ARENA_BINDING
470+ // ! Overrides constraints and forces initialization of internal representation
443471 void initialize (constraints constraints_, unsigned reserved_slots = 1 ,
444472 priority a_priority = priority::normal
445473#if __TBB_PREVIEW_PARALLEL_PHASE
@@ -462,6 +490,37 @@ class task_arena : public task_arena_base {
462490 mark_initialized ();
463491 }
464492 }
493+
494+ #if __TBB_PREVIEW_TASK_ARENA_CORE_TYPE_SELECTOR
495+ // ! Overrides constraints with a custom selector for core types and forces initialization of internal representation
496+ template <typename Selector,
497+ typename = decltype (static_cast <int >(std::declval<Selector>()(std::declval<std::tuple<int , size_t , size_t >>())))>
498+ void initialize (constraints constraints_, Selector selector_,
499+ unsigned reserved_for_masters = 1 , priority a_priority = priority::normal
500+ #if __TBB_PREVIEW_PARALLEL_PHASE
501+ , leave_policy lp = leave_policy::automatic
502+ #endif
503+ )
504+ {
505+ __TBB_ASSERT (!my_arena.load (std::memory_order_relaxed), " Impossible to modify settings of an already initialized task_arena" );
506+ if ( !is_active () ) {
507+ my_numa_id = constraints_.numa_id ;
508+ my_max_concurrency = constraints_.max_concurrency ;
509+ my_core_type = constraints_.core_type ;
510+ my_max_threads_per_core = constraints_.max_threads_per_core ;
511+ my_num_reserved_slots = reserved_for_masters;
512+ my_priority = a_priority;
513+ #if __TBB_PREVIEW_PARALLEL_PHASE
514+ set_leave_policy (lp);
515+ #endif
516+ if (my_core_type == selectable) {
517+ my_core_type = apply_core_type_selector (selector_);
518+ }
519+ r1::initialize (*this );
520+ mark_initialized ();
521+ }
522+ }
523+ #endif /* __TBB_PREVIEW_TASK_ARENA_CORE_TYPE_SELECTOR*/
465524#endif /* __TBB_ARENA_BINDING*/
466525
467526 // ! Attaches this instance to the current arena of the thread
0 commit comments