TaskGroup#
Fully qualified name: carb::tasking::TaskGroup
Defined in carb/tasking/TaskingUtils.h
-
class TaskGroup#
TaskGroup is a small and fast counter for tasks.
TaskGroup blocks when tasks have “entered” the TaskGroup. It becomes signaled when all tasks have left the TaskGroup.
Public Functions
-
inline ~TaskGroup()#
TaskGroup destructor.
Warning
It is an error to destroy a TaskGroup that is not empty. Doing so can result in memory corruption.
-
inline bool empty() const#
Returns (with high probability) whether the TaskGroup is empty.
As TaskGroup atomically tracks tasks, this function may return an incorrect value as another task may have entered or left the TaskGroup before the return value could be processed.
- Returns:
trueif there is high probability that the TaskGroup is empty (signaled);falseotherwise.
-
inline bool try_wait() const#
Returns
trueif the TaskGroup is empty (signaled) with high probability.- Returns:
trueif there is high probability that the TaskGroup is empty (signaled);falseotherwise.
-
template<class Rep, class Period>
inline bool try_wait_for(
)# Blocks the calling thread or task until the TaskGroup becomes empty or the given duration elapses.
- Parameters:
dur – The duration to wait for.
- Returns:
trueif the TaskGroup has become empty;falseif the duration elapses.
-
template<class Clock, class Duration>
inline bool try_wait_until(
)# Blocks the calling thread or task until the TaskGroup becomes empty or the given time is reached.
- Parameters:
when – The time to wait until.
- Returns:
trueif the TaskGroup has become empty;falseif the given time is reached.
-
template<class ...Args>
inline auto with(Args&&... args)# A helper function for entering the TaskGroup during a call to
invoke()and leaving afterwards.- Parameters:
args – Arguments to pass to
carb::cpp::invoke. The TaskGroup is entered (via enter()) before the invoke and left (via leave()) when the invoke completes.- Returns:
the value returned by
carb::cpp::invoke.
-
inline ~TaskGroup()#