task_group¶
[scheduler.task_group]
A task_group represents concurrent execution of a group of tasks.
Tasks may be dynamically added to the group as it is executing.
// Defined in header <tbb/task_group.h>
namespace tbb {
class task_group {
public:
task_group();
~task_group();
template<typename Func>
void run( Func&& f );
template<typename Func>
task_group_status run_and_wait( const Func& f );
task_group_status wait();
bool is_canceling();
void cancel();
};
bool is_current_task_group_canceling();
} // namespace tbb
Member functions¶
-
task_group()¶ Constructs an empty
task_group.
-
~task_group()¶ Destroys the
task_group.Requires: Method
waitmust be called before destroying atask_group, otherwise the destructor throws an exception.
-
template<typename
Func>
voidrun(Func &&f)¶ Adds a task to compute
f()and returns immediately. TheFunctype shall meet the Function Objects requirements from [function.objects] ISO C++ Standard section.
-
template<typename
Func>
task_group_statusrun_and_wait(const Func &f)¶ Equivalent to
{run(f); return wait();}, but guarantees thatf()runs on the current thread. TheFunctype shall meet the Function Objects requirements from [function.objects] ISO C++ Standard section.Returns: The status of
task_group. See task_group_status.
-
task_group_status
wait()¶ Waits for all tasks in the group to complete or be cancelled.
Returns: The status of
task_group. See task_group_status.
-
bool
is_canceling()¶ Returns: True if this task group is cancelling its tasks.
-
void
cancel()¶ Cancels all tasks in this
task_group.