|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Minimal structured-concurrency helper over ThreadPool futures. More...
#include <thread_pool.H>
Public Member Functions | |
| TaskGroup (ThreadPool &pool=default_pool()) noexcept | |
| TaskGroup (const TaskGroup &)=delete | |
| Deleted copy constructor. | |
| TaskGroup & | operator= (const TaskGroup &)=delete |
| Deleted copy assignment operator. | |
| TaskGroup (TaskGroup &&)=delete | |
| Deleted move constructor. | |
| TaskGroup & | operator= (TaskGroup &&)=delete |
| Deleted move assignment operator. | |
| ~TaskGroup () | |
| template<typename F , typename... Args> | |
| void | launch (F &&f, Args &&... args) |
| Launch a task that belongs to this group. | |
| template<typename F , typename... Args> | |
| void | run (F &&f, Args &&... args) |
| Compatibility wrapper for launch(). | |
| void | wait () |
| Wait for all launched tasks and rethrow the first exception. | |
| size_t | size () const noexcept |
| Return the number of tasks currently tracked by the group. | |
| bool | is_empty () const noexcept |
| Return true if the group has no pending tasks. | |
Private Member Functions | |
| void | drain (const bool propagate) |
Static Private Member Functions | |
| template<typename F , typename... Args> | |
| static auto | make_invocable (F &&f, Args &&... args) |
Private Attributes | |
| ThreadPool * | pool_ = nullptr |
| std::vector< std::future< void > > | tasks_ |
Minimal structured-concurrency helper over ThreadPool futures.
A TaskGroup lets callers launch a set of related tasks and then wait for all of them as a unit. Exceptions are propagated cleanly from wait(), and the destructor joins outstanding tasks without throwing.
Definition at line 2536 of file thread_pool.H.
|
inlineexplicitnoexcept |
Definition at line 2575 of file thread_pool.H.
References Aleph::default_pool().
|
delete |
Deleted copy constructor.
|
delete |
Deleted move constructor.
|
inline |
Definition at line 2590 of file thread_pool.H.
|
inlineprivate |
Definition at line 2554 of file thread_pool.H.
|
inlinenoexcept |
Return true if the group has no pending tasks.
Definition at line 2620 of file thread_pool.H.
|
inline |
Launch a task that belongs to this group.
Definition at line 2594 of file thread_pool.H.
References Aleph::ThreadPool::enqueue().
Referenced by example_channels_and_shared_state(), example_structured_concurrency(), main(), TEST(), TEST_F(), and TEST_F().
|
inlinestaticprivate |
Definition at line 2542 of file thread_pool.H.
Deleted copy assignment operator.
|
inline |
Compatibility wrapper for launch().
Definition at line 2608 of file thread_pool.H.
|
inlinenoexcept |
Return the number of tasks currently tracked by the group.
Definition at line 2617 of file thread_pool.H.
Referenced by TEST_F().
|
inline |
Wait for all launched tasks and rethrow the first exception.
Definition at line 2614 of file thread_pool.H.
|
private |
Definition at line 2538 of file thread_pool.H.
|
private |
Definition at line 2539 of file thread_pool.H.