Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
uni20::async::EpochContext Class Reference

#include <epoch_context.hpp>

Classes

struct  DebugSnapshot
 
struct  TaskState
 

Public Types

enum class  Phase {
  Pending , Started , Writing , Reading ,
  Finished
}
 

Public Member Functions

DebugSnapshot debug_snapshot () const
 Return a point-in-time snapshot of epoch state and queued tasks.
 
 EpochContext ()
 
 EpochContext (std::shared_ptr< EpochContext > next)
 Construct an EpochContext given an existing next epoch.
 
std::vector< std::coroutine_handle<> > reader_task_handles () const
 Return coroutine handles currently queued as readers in this epoch context.
 
void set_next_epoch (std::shared_ptr< EpochContext > next)
 Set the next EpochContext in the chain.
 
void start ()
 
void start (std::exception_ptr eptr)
 
void start_reading ()
 
bool try_debug_snapshot (DebugSnapshot &snapshot) const
 Try to return a point-in-time snapshot without blocking.
 
std::vector< std::coroutine_handle<> > writer_task_handles () const
 Return coroutine handles currently queued as writers in this epoch context.
 
 ~EpochContext ()
 

Static Public Member Functions

static std::shared_ptr< EpochContext > make_previous (std::shared_ptr< EpochContext > next)
 Helper factory to construct the previous epoch in a reverse-mode chain.
 

Friends

template<typename T >
class EpochContextReader
 
template<typename T >
class EpochContextWriter
 
class EpochQueue
 
void propagate_unhandled_writer_exception (EpochContext *epoch, std::exception_ptr eptr) noexcept
 Inject an unhandled writer-side coroutine exception into an epoch.
 
class ReverseEpochQueue
 

Member Enumeration Documentation

◆ Phase

Enumerator
Pending 

The epoch is not yet active (i.e. it is in the future)

Started 

The epoch has started but is waiting for a writer task.

Writing 

The epoch is active and waiting for the writers to finish, with no writer currently running.

Reading 

The epoch is active and waiting for readers to finish.

Finished 

The epoch is not active, and readers have finished.

Constructor & Destructor Documentation

◆ EpochContext() [1/2]

uni20::async::EpochContext::EpochContext ( )
inline

◆ EpochContext() [2/2]

uni20::async::EpochContext::EpochContext ( std::shared_ptr< EpochContext >  next)
inlineexplicit

Construct an EpochContext given an existing next epoch.

Note
this is backwards propogation, the counter is initialized to next->counter_ - 1

◆ ~EpochContext()

uni20::async::EpochContext::~EpochContext ( )
inline

Member Function Documentation

◆ debug_snapshot()

DebugSnapshot uni20::async::EpochContext::debug_snapshot ( ) const
inline

Return a point-in-time snapshot of epoch state and queued tasks.

◆ make_previous()

static std::shared_ptr< EpochContext > uni20::async::EpochContext::make_previous ( std::shared_ptr< EpochContext >  next)
inlinestatic

Helper factory to construct the previous epoch in a reverse-mode chain.

◆ reader_task_handles()

std::vector< std::coroutine_handle<> > uni20::async::EpochContext::reader_task_handles ( ) const
inline

Return coroutine handles currently queued as readers in this epoch context.

◆ set_next_epoch()

void uni20::async::EpochContext::set_next_epoch ( std::shared_ptr< EpochContext >  next)
inline

Set the next EpochContext in the chain.

◆ start() [1/2]

void uni20::async::EpochContext::start ( )
inline

◆ start() [2/2]

void uni20::async::EpochContext::start ( std::exception_ptr  eptr)
inline

◆ start_reading()

void uni20::async::EpochContext::start_reading ( )
inline

◆ try_debug_snapshot()

bool uni20::async::EpochContext::try_debug_snapshot ( DebugSnapshot &  snapshot) const
inline

Try to return a point-in-time snapshot without blocking.

Parameters
snapshotDestination for the snapshot when the lock is acquired.
Returns
true if the snapshot was acquired; false if the epoch lock was busy.

◆ writer_task_handles()

std::vector< std::coroutine_handle<> > uni20::async::EpochContext::writer_task_handles ( ) const
inline

Return coroutine handles currently queued as writers in this epoch context.

Friends And Related Symbol Documentation

◆ EpochContextReader

template<typename T >
friend class EpochContextReader
friend

◆ EpochContextWriter

template<typename T >
friend class EpochContextWriter
friend

◆ EpochQueue

friend class EpochQueue
friend

◆ propagate_unhandled_writer_exception

void propagate_unhandled_writer_exception ( EpochContext *  epoch,
std::exception_ptr  eptr 
)
friend

Inject an unhandled writer-side coroutine exception into an epoch.

Parameters
epochTarget epoch context associated with a writer buffer.
eptrException captured by the coroutine promise.

◆ ReverseEpochQueue

friend class ReverseEpochQueue
friend

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