|
Aleph-w 3.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 2331 of file thread_pool.H.
|
inlineexplicitnoexcept |
Definition at line 2370 of file thread_pool.H.
References Aleph::default_pool().
|
delete |
Deleted move constructor.
|
inline |
Definition at line 2385 of file thread_pool.H.
Definition at line 2349 of file thread_pool.H.
|
inlinenoexcept |
Return true if the group has no pending tasks.
Definition at line 2415 of file thread_pool.H.
Launch a task that belongs to this group.
Definition at line 2389 of file thread_pool.H.
References Aleph::ThreadPool::enqueue().
Definition at line 2337 of file thread_pool.H.
Deleted copy assignment operator.
Compatibility wrapper for launch().
Definition at line 2403 of file thread_pool.H.
|
inlinenoexcept |
Return the number of tasks currently tracked by the group.
Definition at line 2412 of file thread_pool.H.
|
inline |
Wait for all launched tasks and rethrow the first exception.
Definition at line 2409 of file thread_pool.H.
|
private |
Definition at line 2333 of file thread_pool.H.
|
private |
Definition at line 2334 of file thread_pool.H.