Intel® oneAPI Threading Building Blocks Developer Guide and API Reference
this_task_arena
[scheduler.this_task_arena]
The namespace for functions applicable to the current task_arena.
The namespace this_task_arena contains global functions for interaction with the task_arena currently used by the calling thread.
// Defined in header <oneapi/tbb/task_arena.h>
namespace oneapi {
namespace tbb {
namespace this_task_arena {
int current_thread_index();
int max_concurrency();
template<typename F> auto isolate(F&& f) -> decltype(f());
template<typename F> void enqueue(F&& f);
template<typename F> void enqueue(F&& f, task_group& tg);
void enqueue(task_handle&& h);
void start_parallel_phase(task_arena::parallel_phase::flags f = {});
void end_parallel_phase(task_arena::parallel_phase::flags f = {});
} // namespace this_task_arena
} // namespace tbb
} // namespace oneapi
intcurrent_thread_index()
Returns the thread index in a task_arena currently used by the calling thread, or task_arena::not_initialized if the thread has not yet initialized the task scheduler.
A thread index is an integer number between 0 and the task_arena concurrency level. Thread indexes are assigned to both application threads and worker threads on joining an arena and are kept until exiting the arena. Indexes of threads that share an arena are unique, that is, no two threads within the arena can have the same index at the same time - but not necessarily consecutive.
intmax_concurrency()
Returns the concurrency level of the task_arena currently used by the calling thread. If the thread has not yet initialized the task scheduler, returns the concurrency level determined automatically for the hardware configuration.
template<typenameF>autoisolate(F&&f)->decltype(f())
Runs the specified functor in isolation by restricting the calling thread to process only tasks scheduled in the scope of the functor (also called the isolation region). The function returns the value returned by the functor. The F type must meet the Function Objects requirements described in the [function.objects] section of the ISO C++ standard.
template<typenameF>voidenqueue(F&&f)
Enqueues a task into the task_arena currently used by the calling thread to process the specified functor, then returns immediately. The F type must meet the Function Objects requirements described in the [function.objects] section of the ISO C++ standard.
Behavior of this function is equivalent to template<typename F> void task_arena::enqueue(F&& f) applied to the task_arena object constructed with attach parameter.
template<typenameF>voidenqueue(F&&f, task_group&tg)
Adds a task to process the specified functor into tg and enqueues it into the task_arena currently used by the calling thread.
The behavior of this function is equivalent to this_task_arena::enqueue( tg.defer(std::forward<F>(f)) ).
voidenqueue(task_handle&&h)
Enqueues a task owned by h into the task_arena that is currently used by the calling thread.
The behavior of this function is equivalent to the generic version (template<typename F> void enqueue(F&& f)), except the parameter type.
voidstart_parallel_phase(task_arena::parallel_phase::flagsf={})
Starts a parallel phase in the task_arena currently used by the calling thread. See parallel_phase.
voidend_parallel_phase(task_arena::parallel_phase::flagsf={})
Ends a parallel phase in the task_arena currently used by the calling thread. See parallel_phase.
See also: