Holder class for spawning child tasks. Allows waiting for all of them to finish.
More...
#include <asyncpp/launch.h>
|
| async_launch_scope (const async_launch_scope &)=delete |
|
async_launch_scope & | operator= (const async_launch_scope &)=delete |
|
template<typename Awaitable , ByteAllocator Allocator = default_allocator_type> |
void | launch (Awaitable &&awaitable, const Allocator &allocator={}) |
| Spawn a new task for the given awaitable.
|
|
template<typename Callable , typename... Args, ByteAllocator Allocator = default_allocator_type>
requires (std::is_invocable_v<Callable, Args...>) |
void | invoke_tuple (Callable &&callable, std::tuple< Args... > &&args, const Allocator &allocator={}) |
| Invoke the provided callable in a new task. The callable is copied into the task, making it save for usage with e.g. lambda captures.
|
|
template<typename Callable , typename... Args>
requires (std::is_invocable_v<Callable, Args...>) |
void | invoke (Callable &&callable, Args &&... args) |
| Invoke the provided callable in a new task. The callable is copied into the task, making it save for usage with e.g. lambda captures.
|
|
auto | join () noexcept |
| Wait for all active tasks to finish.
|
|
template<ByteAllocator Allocator = default_allocator_type> |
std::future< void > | join_future (const Allocator &allocator={}) noexcept |
| Create a future that finishes once all tasks are done. This is equivalent to awaiting join() in a promise.
|
|
size_t | inflight_coroutines () const noexcept |
| Returns the number of active task on this scope.
|
|
bool | all_done () const noexcept |
| Returns true if there is no active task currently running on this scope.
|
|
Holder class for spawning child tasks. Allows waiting for all of them to finish.
◆ inflight_coroutines()
size_t asyncpp::async_launch_scope::inflight_coroutines |
( |
| ) |
const |
|
inlinenoexcept |
Returns the number of active task on this scope.
- Warning
- Only use this value for informational purposes, it might change at any time.
◆ invoke()
template<typename Callable , typename... Args>
requires (std::is_invocable_v<Callable, Args...>)
void asyncpp::async_launch_scope::invoke |
( |
Callable && | callable, |
|
|
Args &&... | args ) |
|
inline |
Invoke the provided callable in a new task. The callable is copied into the task, making it save for usage with e.g. lambda captures.
- Note
- If you need to use a custom allocator use the tuple overload
- Parameters
-
callable | The callable to invoke |
args | The arguments to pass into callable on invocation |
◆ invoke_tuple()
template<typename Callable , typename... Args, ByteAllocator Allocator = default_allocator_type>
requires (std::is_invocable_v<Callable, Args...>)
void asyncpp::async_launch_scope::invoke_tuple |
( |
Callable && | callable, |
|
|
std::tuple< Args... > && | args, |
|
|
const Allocator & | allocator = {} ) |
|
inline |
Invoke the provided callable in a new task. The callable is copied into the task, making it save for usage with e.g. lambda captures.
- Parameters
-
callable | The callable to invoke |
args | The arguments to pass into callable on invocation |
allocator | Allocator used for allocating the wrapper task |
◆ join()
auto asyncpp::async_launch_scope::join |
( |
| ) |
|
|
inlinenoexcept |
Wait for all active tasks to finish.
- Returns
- auto Awaiter that pauses the current coroutine until all spawned task have finished.
◆ join_future()
template<ByteAllocator Allocator = default_allocator_type>
std::future< void > asyncpp::async_launch_scope::join_future |
( |
const Allocator & | allocator = {} | ) |
|
|
inlinenoexcept |
Create a future that finishes once all tasks are done. This is equivalent to awaiting join() in a promise.
- Returns
- std::future waiting for all tasks
◆ launch()
template<typename Awaitable , ByteAllocator Allocator = default_allocator_type>
void asyncpp::async_launch_scope::launch |
( |
Awaitable && | awaitable, |
|
|
const Allocator & | allocator = {} ) |
|
inline |
Spawn a new task for the given awaitable.
- Parameters
-
awaitable | Awaitable to run |
allocator | Allocator used for allocating the wrapper task |
The documentation for this class was generated from the following file: