|
Uni20
Asynchronous tensor and runtime library.
|
RAII handle for reading the value from an Async container at a given epoch. More...
#include <buffers.hpp>
Public Types | |
| using | value_type = T |
Public Member Functions | |
| bool | await_ready () const noexcept |
| Check if the value is already ready to be read. | |
| OwningReadAccessProxy< T > | await_resume () && |
| Resume execution and return an owning read proxy. | |
| T const & | await_resume () const & |
| Resume execution and return the stored value. | |
| void | await_suspend (BasicTask &&t) noexcept |
| Suspend this coroutine and enqueue for resumption. | |
| std::shared_ptr< EpochContext > | epoch_context_shared () const noexcept |
| Returns the epoch context used for exception propagation. | |
| T const & | get_wait () const |
| Block until the read value is available. | |
| T const & | get_wait (IAsyncScheduler &sched) const |
| Block using an explicit scheduler until the read value is available. | |
| ReadMaybeAwaiter< T const & > | maybe () & |
Returns a ReadMaybeAwaiter. | |
| ReadMaybeAwaiter< T > | maybe () && |
Returns a ReadMaybeAwaiter consuming this read buffer. | |
| auto | operator co_await () &&noexcept -> OwningReadAwaiter< T > |
| Enable co_await on rvalue ReadBuffer and transfer ownership to an owning read proxy. | |
| auto | operator co_await () &noexcept -> ReadBuffer & |
| Enable co_await on lvalue ReadBuffer and return a borrowed reference. | |
| auto | operator co_await () const &noexcept -> ReadBuffer const & |
| ReadBuffer & | operator= (ReadBuffer &&other) noexcept |
| Move assignment. | |
| ReadBuffer & | operator= (ReadBuffer const &)=delete |
| ReadOrCancelAwaiter< T const & > | or_cancel () & |
Returns a ReadOrCancelAwaiter. | |
| ReadOrCancelAwaiter< T > | or_cancel () && |
Returns a ReadOrCancelAwaiter consuming this read buffer. | |
| ReadBuffer (EpochContextReader< T > reader) | |
| Construct a read buffer tied to a reader context. | |
| ReadBuffer (ReadBuffer &&other) noexcept | |
| Move constructor. | |
| ReadBuffer (ReadBuffer const &other) | |
| Copy constructor; duplicates read handle and exception sink registration. | |
| void | register_exception_sink (TaskPromiseBase &promise, bool explicit_sink) const |
| Register this buffer as an exception sink with a promise. | |
| void | release () noexcept |
| Manually release the epoch reader before awaitable destruction. | |
| ReadBuffer && | transfer () &&noexcept |
| Transfer this read buffer into the owning-await path. | |
| ReadBuffer && | transfer () &noexcept |
| Transfer this read buffer into the owning-await path. | |
| void | wait () const |
| Block until the read value is available. | |
| void | wait (IAsyncScheduler &sched) const |
| Block using an explicit scheduler until the read value is available. | |
| ~ReadBuffer () noexcept | |
| Destructor unregisters any attached exception sink. | |
RAII handle for reading the value from an Async container at a given epoch.
A ReadBuffer<T> represents a read-only access to the value of an Async<T> at a specific epoch. It is awaitable, and yields either a borrowed reference or an owning proxy depending on value category:
co_await buf yields T const&: shared read access.co_await buf.transfer() yields an owning proxy that keeps the read epoch alive.transfer() is the explicit owning form for named buffers. Direct co_await on a temporary buffer still uses the owning rvalue path.ReadBuffer<T> can be co_awaited multiple times, but buf.transfer() transfers ownership semantics and should only be used once. After moving, further use is undefined.| T | The underlying value type. |
| using uni20::async::ReadBuffer< T >::value_type = T |
|
inline |
Construct a read buffer tied to a reader context.
| reader | The RAII epoch reader handle for this operation. |
|
inline |
Copy constructor; duplicates read handle and exception sink registration.
| other | Source read buffer. |
|
inlinenoexcept |
Move constructor.
| other | Source read buffer. |
|
inlinenoexcept |
Destructor unregisters any attached exception sink.
|
inlinenoexcept |
Check if the value is already ready to be read.
| OwningReadAccessProxy< T > uni20::async::ReadBuffer< T >::await_resume | ( | ) | && |
Resume execution and return an owning read proxy.
|
inline |
Resume execution and return the stored value.
|
inlinenoexcept |
Suspend this coroutine and enqueue for resumption.
| t | Coroutine task to enqueue. |
|
inlinenoexcept |
Returns the epoch context used for exception propagation.
|
inline |
Block until the read value is available.
|
inline |
Block using an explicit scheduler until the read value is available.
| sched | Scheduler used to drive progress. |
| ReadMaybeAwaiter< T const & > uni20::async::ReadBuffer< T >::maybe | ( | ) | & |
Returns a ReadMaybeAwaiter.
Lvalue reads return T const*; moved reads return std::optional<OwningReadAccessProxy<T>>.
| ReadMaybeAwaiter< T > uni20::async::ReadBuffer< T >::maybe | ( | ) | && |
Returns a ReadMaybeAwaiter consuming this read buffer.
Build a maybe-awaiter from an rvalue read buffer.
Moved reads return std::optional<OwningReadAccessProxy<T>>.
| T | Stored value type. |
|
inlinenoexcept |
Enable co_await on rvalue ReadBuffer and transfer ownership to an owning read proxy.
|
inlinenoexcept |
Enable co_await on lvalue ReadBuffer and return a borrowed reference.
|
inlinenoexcept |
|
inlinenoexcept |
Move assignment.
| other | Source read buffer. |
*this.
|
delete |
| ReadOrCancelAwaiter< T const & > uni20::async::ReadBuffer< T >::or_cancel | ( | ) | & |
Returns a ReadOrCancelAwaiter.
Lvalue reads return T const& and throw task_cancelled when no value was written. Exceptions stored by a failed writer propagate unchanged.
| ReadOrCancelAwaiter< T > uni20::async::ReadBuffer< T >::or_cancel | ( | ) | && |
Returns a ReadOrCancelAwaiter consuming this read buffer.
Build an or-cancel awaiter from an rvalue read buffer.
Moved reads return OwningReadAccessProxy<T> and throw task_cancelled when no value was written. Exceptions stored by a failed writer propagate unchanged.
| T | Stored value type. |
|
inline |
Register this buffer as an exception sink with a promise.
| promise | Promise that owns the sink list. |
| explicit_sink | Whether this sink came from propagate_exceptions_to. |
|
inlinenoexcept |
Manually release the epoch reader before awaitable destruction.
This allows the coroutine to relinquish its reader role earlier than its full lifetime.
release() more than once has no effect.
|
inlinenoexcept |
Transfer this read buffer into the owning-await path.
*this.
|
inlinenoexcept |
Transfer this read buffer into the owning-await path.
*this.
|
inline |
Block until the read value is available.
|
inline |
Block using an explicit scheduler until the read value is available.
| sched | Scheduler used to drive progress. |