Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
uni20::async::AllAwaiter< Aw > Struct Template Reference

Awaitable that waits for all provided awaiters to complete. More...

#include <awaiters.hpp>

Public Member Functions

bool await_ready () noexcept
 Check if all awaiters are ready.
 
auto await_resume ()
 Resume all awaiters and collect their results.
 
void await_suspend (TaskFactory f) noexcept
 Suspend the coroutine on awaiters not yet ready.
 
int num_awaiters () const noexcept
 Return the number of awaiters, needed by the TaskFactory model.
 

Public Attributes

std::tuple< Aw... > bufs_
 Underlying awaiters.
 
int pending_ = sizeof...(Aw)
 Number of awaiters that still need to suspend.
 
std::array< bool, sizeof...(Aw)> ready_ {}
 Readiness flags.
 

Detailed Description

template<TaskFactoryChildAwaitable... Aw>
requires ((!std::is_void_v<decltype(std::declval<Aw>().await_resume())> && ...))
struct uni20::async::AllAwaiter< Aw >

Awaitable that waits for all provided awaiters to complete.

This meets the TaskFactoryAwaitable concept.

Template Parameters
AwRegistration-style awaiters that return void from await_suspend(BasicTask).
Note
the child await_resume() functions must return a non-void.
Todo:
We currently don't allow nested waiting on TaskFactoryAwaitable children. This could be supported, if it was useful.

Member Function Documentation

◆ await_ready()

template<TaskFactoryChildAwaitable... Aw>
bool uni20::async::AllAwaiter< Aw >::await_ready ( )
inlinenoexcept

Check if all awaiters are ready.

Returns
true if no suspension is required.

◆ await_resume()

template<TaskFactoryChildAwaitable... Aw>
auto uni20::async::AllAwaiter< Aw >::await_resume ( )
inline

Resume all awaiters and collect their results.

Referenced child awaiters resume as lvalues, while child awaiters owned by this join resume as rvalues. The result tuple preserves lvalue references and owns value or rvalue-reference results.

Returns
Tuple containing each child result with a safe lifetime.

◆ await_suspend()

template<TaskFactoryChildAwaitable... Aw>
void uni20::async::AllAwaiter< Aw >::await_suspend ( TaskFactory  f)
inlinenoexcept

Suspend the coroutine on awaiters not yet ready.

Template Parameters
PromiseThe coroutine’s promise type.
Parameters
fTaskFactory that provides one BasicTask per sub-awaitable

◆ num_awaiters()

template<TaskFactoryChildAwaitable... Aw>
int uni20::async::AllAwaiter< Aw >::num_awaiters ( ) const
inlinenoexcept

Return the number of awaiters, needed by the TaskFactory model.

Note
It is safe to over-allocate: unused BasicTasks will be returned in the factory destructor.

Member Data Documentation

◆ bufs_

template<TaskFactoryChildAwaitable... Aw>
std::tuple<Aw...> uni20::async::AllAwaiter< Aw >::bufs_

Underlying awaiters.

◆ pending_

template<TaskFactoryChildAwaitable... Aw>
int uni20::async::AllAwaiter< Aw >::pending_ = sizeof...(Aw)

Number of awaiters that still need to suspend.

◆ ready_

template<TaskFactoryChildAwaitable... Aw>
std::array<bool, sizeof...(Aw)> uni20::async::AllAwaiter< Aw >::ready_ {}

Readiness flags.


The documentation for this struct was generated from the following file: