Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
uni20::async::EpochContextWriter< T > Class Template Reference

RAII-scoped representation of a writer’s participation in an epoch. More...

#include <epoch_context.hpp>

Public Member Functions

T & data () const
 Access the stored data while holding the writer gate.
 
template<typename... Args>
requires std::constructible_from<T, Args...>
T & emplace (Args &&... args)
 
std::shared_ptr< EpochContext > epoch_context_shared () const noexcept
 
 EpochContextWriter ()=delete
 
 EpochContextWriter (EpochContextWriter &&other) noexcept
 Move constructor transferring the writer handle.
 
 EpochContextWriter (shared_storage< T > storage, std::shared_ptr< EpochContext > epoch) noexcept
 Construct an active writer.
 
T && move_from_wait ()
 Wait for the epoch to become available, and then return a prvalue-reference to the value.
 
 operator bool () const noexcept
 Copy constructor acquiring a writer reference for diagnostics.
 
EpochContextWriter & operator= (EpochContextWriter &&other) noexcept
 Move assignment transferring the writer handle.
 
EpochContextWriter & operator= (EpochContextWriter const &)=delete
 
bool ready () const noexcept
 Check whether the writer may proceed immediately.
 
void release () noexcept
 Wait for the epoch to become available, and then return a prvalue-reference to the value.
 
void resume () const noexcept
 
void set_exception (std::exception_ptr e) const noexcept
 
shared_storage< T > & storage ()
 
void suspend (BasicTask &&t)
 Suspend the writer task and submit to the epoch context.
 
bool value_is_initialized () const noexcept
 Report whether the associated value is currently initialized.
 
 ~EpochContextWriter ()
 Destructor releasing any held writer epoch.
 

Detailed Description

template<typename T>
class uni20::async::EpochContextWriter< T >

RAII-scoped representation of a writer’s participation in an epoch.

Constructed by EpochQueue and passed into a WriteBuffer<T>, this class manages the binding and release of a writer coroutine to a single EpochContext. It ensures that the write gate is completed exactly once, either manually via release() or automatically on destruction.

Constructor & Destructor Documentation

◆ EpochContextWriter() [1/3]

template<typename T >
uni20::async::EpochContextWriter< T >::EpochContextWriter ( )
delete

◆ EpochContextWriter() [2/3]

template<typename T >
uni20::async::EpochContextWriter< T >::EpochContextWriter ( shared_storage< T >  storage,
std::shared_ptr< EpochContext >  epoch 
)
inlinenoexcept

Construct an active writer.

Parameters
valueShared pointer to the stored value.
epochEpoch tracked by this writer.

◆ EpochContextWriter() [3/3]

template<typename T >
uni20::async::EpochContextWriter< T >::EpochContextWriter ( EpochContextWriter< T > &&  other)
inlinenoexcept

Move constructor transferring the writer handle.

Parameters
otherWriter being moved from.

◆ ~EpochContextWriter()

template<typename T >
uni20::async::EpochContextWriter< T >::~EpochContextWriter ( )
inline

Destructor releasing any held writer epoch.

Member Function Documentation

◆ data()

template<typename T >
T & uni20::async::EpochContextWriter< T >::data ( ) const
inline

Access the stored data while holding the writer gate.

Returns
Mutable reference to the stored value.
Exceptions
buffer_write_uninitializedif storage is not yet constructed.

◆ emplace()

template<typename T >
template<typename... Args>
requires std::constructible_from<T, Args...>
T & uni20::async::EpochContextWriter< T >::emplace ( Args &&...  args)
inline

◆ epoch_context_shared()

template<typename T >
std::shared_ptr< EpochContext > uni20::async::EpochContextWriter< T >::epoch_context_shared ( ) const
inlinenoexcept

◆ move_from_wait()

template<typename T >
T && uni20::async::EpochContextWriter< T >::move_from_wait ( )

Wait for the epoch to become available, and then return a prvalue-reference to the value.

Wait for a writer context and move out the stored value.

Template Parameters
TStored value type.
Returns
Moved value from writer storage.

◆ operator bool()

template<typename T >
uni20::async::EpochContextWriter< T >::operator bool ( ) const
inlineexplicitnoexcept

Copy constructor acquiring a writer reference for diagnostics.

◆ operator=() [1/2]

template<typename T >
EpochContextWriter & uni20::async::EpochContextWriter< T >::operator= ( EpochContextWriter< T > &&  other)
inlinenoexcept

Move assignment transferring the writer handle.

Parameters
otherWriter being moved from.
Returns
Reference to *this after transfer.

◆ operator=() [2/2]

template<typename T >
EpochContextWriter & uni20::async::EpochContextWriter< T >::operator= ( EpochContextWriter< T > const &  )
delete

◆ ready()

template<typename T >
bool uni20::async::EpochContextWriter< T >::ready ( ) const
inlinenoexcept

Check whether the writer may proceed immediately.

Note
If true, then the writer is now active

◆ release()

template<typename T >
void uni20::async::EpochContextWriter< T >::release ( )
inlinenoexcept

Wait for the epoch to become available, and then return a prvalue-reference to the value.

Finalize this write gate, if not already done.

◆ resume()

template<typename T >
void uni20::async::EpochContextWriter< T >::resume ( ) const
inlinenoexcept

◆ set_exception()

template<typename T >
void uni20::async::EpochContextWriter< T >::set_exception ( std::exception_ptr  e) const
inlinenoexcept

◆ storage()

template<typename T >
shared_storage< T > & uni20::async::EpochContextWriter< T >::storage ( )
inline

◆ suspend()

template<typename T >
void uni20::async::EpochContextWriter< T >::suspend ( BasicTask &&  t)
inline

Suspend the writer task and submit to the epoch context.

Parameters
tThe coroutine to bind and schedule.

◆ value_is_initialized()

template<typename T >
bool uni20::async::EpochContextWriter< T >::value_is_initialized ( ) const
inlinenoexcept

Report whether the associated value is currently initialized.

Returns
true if the epoch reports initialized storage.

The documentation for this class was generated from the following files: