|
Uni20
Asynchronous tensor and runtime library.
|
Async<T> is a container for coroutine-safe asynchronous read/write. More...
#include <async.hpp>
Public Types | |
| using | value_type = T |
Public Member Functions | |
| Async () | |
| Initializes async state without constructing the stored value. | |
| template<typename... Args> requires (std::constructible_from<T, Args...> && !is_async_alias_v<T>) | |
| Async (Args &&... args) | |
| Construct the stored value in place using forwarded arguments. | |
| Async (Async &&other) noexcept=default | |
| Move-construct from another Async<T> handle. | |
| Async (Async const &)=delete | |
| Forbid copying an independent async value whose payload cannot be copy-constructed. | |
| Async (Async const &rhs) | |
| Construct a new Async<T> by copying the value from another Async<T>. | |
| Async (Async const &rhs) | |
| Structurally copy an async alias handle. | |
| Async (async_do_not_start_t tag) | |
| Initializes async state without constructing the stored value or starting the queue. | |
| template<typename U , typename... Args> requires (std::constructible_from<T, std::initializer_list<U>&, Args...> && !is_async_alias_v<T>) | |
| Async (std::initializer_list< U > init, Args &&... args) | |
| Construct the stored value in place from an initializer list. | |
| template<typename U > requires (std::constructible_from<T, U> && (!std::convertible_to<U, T>) && !is_async_alias_v<T>) | |
| Async (U &&u) | |
| Explicitly construct from a value that requires explicit conversion. | |
| template<typename U > requires (std::convertible_to<U, T> && !is_async_alias_v<T>) | |
| Async (U &&val) | |
| Construct from a value convertible to T. | |
| Async & | debug_name (std::string const &label) |
| Assign an optional debug label for task-registry graph output. | |
| Async const & | debug_name (std::string const &label) const |
| Assign an optional debug label for task-registry graph output. | |
| T const & | get_wait () const |
| Block the current thread until the value becomes available. | |
| T const & | get_wait (IAsyncScheduler &sched) const |
| Block using an explicit scheduler until the value is ready. | |
| T | move_from_wait () |
| Block until the value is available, then move it out of the Async. | |
| Async & | operator= (Async &&)=delete |
| Forbid assignment to a read-only async alias. | |
| Async & | operator= (Async &&other) |
| Assign through a mutable async alias from an exact-type rvalue alias. | |
| Async & | operator= (Async &&other) noexcept |
| Rebind an independent async value from another Async<T> handle. | |
| Async & | operator= (Async const &)=delete |
| Forbid copy assignment when an independent payload cannot be copy-constructed. | |
| Async & | operator= (Async const &)=delete |
| Forbid assignment to a read-only async alias. | |
| Async & | operator= (Async const &rhs) |
| Copy-assign from another Async<T>, overwriting this instance's value timeline. | |
| Async & | operator= (Async const &rhs) |
| Assign through a mutable async alias from another exact-type alias. | |
| template<typename U > requires detail::async_assignment_source<T, U> | |
| Async & | operator= (U &&rhs) |
| Assign an immediate or heterogeneous async value. | |
| template<typename U > requires detail::async_assignment_source<T, U> | |
| Async< T > & | operator= (U &&rhs) |
| EpochQueue const & | queue () const |
| Inspect the shared epoch queue. | |
| ReadBuffer< T > | read () const |
| Begin an asynchronous read of the value. | |
| shared_storage< T > const & | storage () const |
| Access the shared storage control block. | |
| T const * | storage_address () const noexcept |
| Return the const address reserved for the contained value when constructing an alias descriptor. | |
| T * | storage_address () noexcept |
| Return the address reserved for the contained value when constructing an alias descriptor. | |
| void | unsafe_set (T const &x) |
| Overwrite the stored value directly. | |
| T | unsafe_value () const |
| Return a copy of the stored value. | |
| T & | unsafe_value_ref () |
| Access the stored value without synchronization. | |
| T const & | unsafe_value_ref () const |
| Access the stored value without synchronization. | |
| std::shared_ptr< T > | value_ptr () |
| Access the mutable stored value pointer with shared ownership semantics. | |
| std::shared_ptr< T const > | value_ptr () const |
| Access the const stored value pointer with shared ownership semantics. | |
| void | wait () const |
| Block the current thread until the value becomes available. | |
| void | wait (IAsyncScheduler &sched) const |
| Block using an explicit scheduler until the value is ready. | |
| WriteBuffer< T > | write () |
| Begin exclusive asynchronous access to the payload. | |
| ~Async ()=default | |
Friends | |
| template<typename Alias , typename Parent , typename... Args> | |
| Async< Alias > | make_async_alias (Async< Parent > const &parent, Args &&... args) |
| Construct an async alias that retains a parent value and shares its epoch queue. | |
| template<typename Alias , typename Parent , typename... Args> | |
| Async< Alias > | make_async_alias_from_parent (Async< Parent > &parent, Args &&... args) |
| Construct an async alias from a mutable parent descriptor. | |
| template<typename Alias , typename Parent , typename... Args> | |
| Async< Alias > | make_async_alias_from_parent (Async< Parent > const &parent, Args &&... args) |
| Construct a read-only async alias from a parent descriptor. | |
| class | ReverseValue< T > |
Async<T> is a container for coroutine-safe asynchronous read/write.
Async<T> stores a value of type T and mediates access through epoch-based coordination. The value, queue, and individual epoch contexts use shared ownership where required. Buffer handles retain their storage and selected epoch context, so they may outlive the owning Async container.
is_async_alias_v<T> is true copy the storage handle, lifetime owner, and dependency timeline instead.ReadBuffer<T> and WriteBuffer<T> may safely outlive the Async. T need not be default-constructible, copyable, or movable. Individual operations participate only when their required construction or assignment expressions are available. | T | Stored value type. |
| using uni20::async::Async< T >::value_type = T |
|
inline |
Initializes async state without constructing the stored value.
|
inline |
Initializes async state without constructing the stored value or starting the queue.
| tag | Sentinel tag selecting non-starting construction. |
|
inline |
Construct from a value convertible to T.
| U | Value type convertible to T. |
| val | Initial value forwarded into the Async storage. |
|
inlineexplicit |
Explicitly construct from a value that requires explicit conversion.
| U | Source type that can explicitly construct T. |
| u | Value forwarded to construct the stored T instance. |
|
inline |
Construct the stored value in place using forwarded arguments.
| Args | Argument types forwarded to T's constructor. |
| args | Arguments used to initialize the contained value. |
|
inline |
Construct the stored value in place from an initializer list.
| U | Element type accepted by T's initializer list constructor. |
| Args | Additional argument types forwarded to T's constructor. |
| init | Initializer list forwarded to T. |
| args | Additional arguments forwarded to T. |
|
inline |
Construct a new Async<T> by copying the value from another Async<T>.
rhs and writes it into the initial epoch of the newly constructed *this.rhs. Coroutine handles, epoch queues, and computation histories are not copied.async_assign for explicit value-level copy scheduling.
|
delete |
Forbid copying an independent async value whose payload cannot be copy-constructed.
|
inline |
Structurally copy an async alias handle.
Alias copies retain the same descriptor storage, lifetime owner, and epoch queue.
|
defaultnoexcept |
Move-construct from another Async<T> handle.
| other | Source Async. |
|
default |
|
inline |
Assign an optional debug label for task-registry graph output.
| label | Human-readable label used only by debug diagnostics. |
|
inline |
Assign an optional debug label for task-registry graph output.
| label | Human-readable label used only by debug diagnostics. |
| T const & uni20::async::Async< T >::get_wait | ( | ) | const |
Block the current thread until the value becomes available.
Waits for the latest readable value and returns a const reference.
| T | Async value type. |
| T const & uni20::async::Async< T >::get_wait | ( | IAsyncScheduler & | sched | ) | const |
Block using an explicit scheduler until the value is ready.
Waits for the latest readable value using an explicit scheduler.
The scheduler will be driven until all pending writers complete, then the value reference is returned. This overload is useful for deterministic execution in tests where the scheduling context must be controlled.
| sched | Scheduler instance used to make progress while waiting. |
| T | Async value type. |
| sched | Scheduler used to drive pending work. |
| T uni20::async::Async< T >::move_from_wait | ( | ) |
|
delete |
Forbid assignment to a read-only async alias.
|
inline |
Assign through a mutable async alias from an exact-type rvalue alias.
| other | Alias whose referenced value is the assignment source. |
|
inlinenoexcept |
Rebind an independent async value from another Async<T> handle.
| other | Source Async. |
|
delete |
Forbid copy assignment when an independent payload cannot be copy-constructed.
|
delete |
Forbid assignment to a read-only async alias.
|
inline |
Copy-assign from another Async<T>, overwriting this instance's value timeline.
*this by move-assigning a fresh Async<T>. It then schedules a coroutine that awaits rhs and writes its result to *this.*this. If you wish to serialize with prior writes, use async_assign(*this, rhs) directly.| rhs | Source Async whose value timeline is copied. |
|
inline |
Assign through a mutable async alias from another exact-type alias.
The destination descriptor, owner, and queue remain unchanged.
| rhs | Alias whose referenced value is the assignment source. |
| Async & uni20::async::Async< T >::operator= | ( | U && | rhs | ) |
Assign an immediate or heterogeneous async value.
Independent values detach onto fresh storage and a fresh epoch queue. Async aliases retain their descriptor, owner, and queue, and participate only when ADL finds a matching assign_through operation. Read-only aliases therefore have no assignment.
| U | Immediate value or heterogeneous async source type. |
| rhs | Source expression. |
| Async< T > & uni20::async::Async< T >::operator= | ( | U && | rhs | ) |
|
inline |
Inspect the shared epoch queue.
Parent values and aliases share this exact mutable queue. Individual buffers retain their selected epoch contexts.
|
inline |
Begin an asynchronous read of the value.
|
inline |
Access the shared storage control block.
|
inlinenoexcept |
Return the const address reserved for the contained value when constructing an alias descriptor.
|
inlinenoexcept |
Return the address reserved for the contained value when constructing an alias descriptor.
|
inline |
Overwrite the stored value directly.
Intended for debugging and test scaffolding where a synchronous update is acceptable. No synchronization with pending writers or readers is performed.
| x | New value to store. |
|
inline |
Return a copy of the stored value.
This helper is primarily for diagnostics; it will throw if the value has not been initialized.
|
inline |
Access the stored value without synchronization.
|
inline |
Access the stored value without synchronization.
|
inline |
Access the mutable stored value pointer with shared ownership semantics.
This overload is unavailable for not_assignable aliases.
The returned pointer retains the shared_storage control block so that the lifetime of the referenced value is tied to the same shared ownership as the Async container itself.
shared_storage control block.
|
inline |
Access the const stored value pointer with shared ownership semantics.
shared_storage control block. | void uni20::async::Async< T >::wait | ( | ) | const |
Block the current thread until the value becomes available.
Waits for the latest readable value without retrieving it.
| T | Async value type. |
| void uni20::async::Async< T >::wait | ( | IAsyncScheduler & | sched | ) | const |
Block using an explicit scheduler until the value is ready.
Waits for the latest readable value using an explicit scheduler without retrieving it.
The scheduler will be driven until all pending writers complete.
| sched | Scheduler instance used to make progress while waiting. |
| T | Async value type. |
| sched | Scheduler used to drive pending work. |
|
inline |
Begin exclusive asynchronous access to the payload.
The returned proxy is capability-aware. Independent values support replacement operations; aliases expose their descriptor read-only and support only matching write-through assignments.
|
friend |
Construct an async alias that retains a parent value and shares its epoch queue.
|
friend |
Construct an async alias from a mutable parent descriptor.
The alias constructor receives the address reserved for the parent value followed by args. The address may identify unconstructed storage and must not be dereferenced before the shared epoch is readable.
|
friend |
Construct a read-only async alias from a parent descriptor.
|
friend |