141 template <
typename F>
165 template <TaskParamsLike P,
typename F>
166 auto async(P&& params, F&& f);
194 template <
typename F>
217 template <TaskParamsLike P,
typename F>
342 template <
typename F, std::input_iterator I>
387 template <TaskParamsLike P,
typename F, std::input_iterator I>
495 template <
typename F, std::input_iterator I>
534 template <TaskParamsLike P,
typename F, std::input_iterator I>
710 _executor {executor},
712 _node_base {NSTATE::IMPLICITLY_ANCHORED, ESTATE::NONE, nullptr, 0} {
723 ExplicitAnchorGuard anchor(&_node_base);
724 _executor._corun_until(_worker, [
this] () ->
bool {
725 return _node_base._join_counter.load(std::memory_order_acquire) == 0;
728 _node_base._rethrow_exception();
733 _node_base._estate.fetch_or(ESTATE::CANCELLED, std::memory_order_relaxed);
738 return _node_base._estate.load(std::memory_order_relaxed) & ESTATE::CANCELLED;
743 return _node_base._join_counter.load(std::memory_order_relaxed);
757template <TaskParamsLike P,
typename F>
759 _node_base._join_counter.fetch_add(1, std::memory_order_relaxed);
760 _executor._silent_async(
761 std::forward<P>(params), std::forward<F>(f),
nullptr, &_node_base
776template <TaskParamsLike P,
typename F>
778 _node_base._join_counter.fetch_add(1, std::memory_order_relaxed);
779 return _executor._async(
780 std::forward<P>(params), std::forward<F>(f),
nullptr, &_node_base
799 P&& params, F&& func, Tasks&&... tasks
801 std::array<
AsyncTask*,
sizeof...(Tasks)> array = { (&tasks)... };
803 std::forward<P>(params), std::forward<F>(func), array.begin(), array.end()
808template <
typename F, std::input_iterator I>
814template <TaskParamsLike P,
typename F, std::input_iterator I>
816 P&& params, F&& func, I first, I last
818 _node_base._join_counter.fetch_add(1, std::memory_order_relaxed);
819 return _executor._silent_dependent_async(
820 std::forward<P>(params), std::forward<F>(func), first, last,
nullptr, &_node_base
837 std::array<
AsyncTask*,
sizeof...(Tasks)> array = { (&tasks)... };
839 std::forward<P>(params), std::forward<F>(func), array.begin(), array.end()
844template <
typename F, std::input_iterator I>
850template <TaskParamsLike P,
typename F, std::input_iterator I>
852 _node_base._join_counter.fetch_add(1, std::memory_order_relaxed);
853 return _executor._dependent_async(
854 std::forward<P>(params), std::forward<F>(func), first, last,
nullptr, &_node_base
866 TF_THROW(
"task_group can only created by a worker of the executor");
class to hold a dependent asynchronous task with shared ownership
Definition async_task.hpp:45
class to create an empty task parameter for compile-time optimization
Definition graph.hpp:191
class to create an executor
Definition executor.hpp:62
TaskGroup task_group()
creates a task group that executes a collection of asynchronous tasks
Definition task_group.hpp:863
Worker * this_worker()
queries pointer to the calling worker if it belongs to this executor, otherwise returns nullptr
class to create a task group from a task
Definition task_group.hpp:61
auto dependent_async(F &&func, Tasks &&... tasks)
runs the given function asynchronously when the given predecessors finish
Definition task_group.hpp:830
void corun()
corun all tasks spawned by this task group with other workers
Definition task_group.hpp:721
void cancel()
cancel all tasks in this task group
Definition task_group.hpp:732
size_t size() const
queries the number of tasks currently in this task group
Definition task_group.hpp:742
tf::AsyncTask silent_dependent_async(F &&func, Tasks &&... tasks)
runs the given function asynchronously when the given predecessors finish
Definition task_group.hpp:790
auto async(F &&f)
runs the given callable asynchronously
Definition task_group.hpp:771
TaskGroup & operator=(TaskGroup &&)=delete
disabled copy assignment
bool is_cancelled()
queries if the task group has been cancelled
Definition task_group.hpp:737
TaskGroup(TaskGroup &&)=delete
disabled move constructor
TaskGroup(const TaskGroup &)=delete
disabled copy constructor
Executor & executor()
obtains the executor that creates this task group
Definition task_group.hpp:716
void silent_async(F &&f)
runs the given function asynchronously without returning any future object
Definition task_group.hpp:752
class to create a worker in an executor
Definition worker.hpp:55
concept to check if a type is a tf::AsyncTask
Definition async_task.hpp:314
concept that determines if a type is a task parameter type
Definition graph.hpp:202
taskflow namespace
Definition small_vector.hpp:20