threadman 0.1.0
Header-only C++23 managed threads, dynamic pools, futures, and executors
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
threadman::TaskHandle Class Reference

#include <task.hpp>

Classes

struct  State
 Heap-resident bookkeeping for a single task. More...
 

Public Member Functions

 TaskHandle (const std::uint64_t id, const std::uint64_t pool_id, std::optional< std::string > name=std::nullopt)
 Construct a handle owning a freshly-allocated State.
 
 TaskHandle ()=default
 
 TaskHandle (const TaskHandle &)=default
 
 TaskHandle (TaskHandle &&) noexcept=default
 
TaskHandleoperator= (const TaskHandle &)=default
 
TaskHandleoperator= (TaskHandle &&) noexcept=default
 
 ~TaskHandle ()=default
 
bool valid () const noexcept
 True iff this handle owns a state.
 
std::uint64_t id () const noexcept
 
std::uint64_t pool_id () const noexcept
 
TaskState state () const noexcept
 
std::optional< std::string > name () const
 
std::shared_ptr< Stateraw () const noexcept
 Direct access to the shared state; used by the pool/future internals.
 
void mark_running () const
 Transition Queued → Running and stamp started_at = now.
 
void mark_completed () const
 Transition Running → Completed and stamp finished_at = now.
 
void mark_failed (const std::exception_ptr &ex) const
 Transition Running → Failed and stamp finished_at = now.
 
void mark_cancelled (const std::exception_ptr &ex=nullptr) const
 Transition any non-terminal state → Cancelled and stamp finished_at.
 
TaskSnapshot snapshot () const
 Consistent snapshot of the task's state.
 

Static Public Member Functions

static const comms::DisplayInfo & display_info ()
 

Constructor & Destructor Documentation

◆ TaskHandle() [1/4]

threadman::TaskHandle::TaskHandle ( const std::uint64_t  id,
const std::uint64_t  pool_id,
std::optional< std::string >  name = std::nullopt 
)
inlineexplicit

Construct a handle owning a freshly-allocated State.

◆ TaskHandle() [2/4]

threadman::TaskHandle::TaskHandle ( )
default

◆ TaskHandle() [3/4]

threadman::TaskHandle::TaskHandle ( const TaskHandle )
default

◆ TaskHandle() [4/4]

threadman::TaskHandle::TaskHandle ( TaskHandle &&  )
defaultnoexcept

◆ ~TaskHandle()

threadman::TaskHandle::~TaskHandle ( )
default

Member Function Documentation

◆ display_info()

static const comms::DisplayInfo & threadman::TaskHandle::display_info ( )
inlinestatic

◆ id()

std::uint64_t threadman::TaskHandle::id ( ) const
inlinenoexcept

◆ mark_cancelled()

void threadman::TaskHandle::mark_cancelled ( const std::exception_ptr &  ex = nullptr) const
inline

Transition any non-terminal state → Cancelled and stamp finished_at.

◆ mark_completed()

void threadman::TaskHandle::mark_completed ( ) const
inline

Transition Running → Completed and stamp finished_at = now.

◆ mark_failed()

void threadman::TaskHandle::mark_failed ( const std::exception_ptr &  ex) const
inline

Transition Running → Failed and stamp finished_at = now.

The caller is responsible for stashing the exception_ptr separately if it wants users of the snapshot to see failed=true.

◆ mark_running()

void threadman::TaskHandle::mark_running ( ) const
inline

Transition Queued → Running and stamp started_at = now.

◆ name()

std::optional< std::string > threadman::TaskHandle::name ( ) const
inline

◆ operator=() [1/2]

TaskHandle & threadman::TaskHandle::operator= ( const TaskHandle )
default

◆ operator=() [2/2]

TaskHandle & threadman::TaskHandle::operator= ( TaskHandle &&  )
defaultnoexcept

◆ pool_id()

std::uint64_t threadman::TaskHandle::pool_id ( ) const
inlinenoexcept

◆ raw()

std::shared_ptr< State > threadman::TaskHandle::raw ( ) const
inlinenoexcept

Direct access to the shared state; used by the pool/future internals.

◆ snapshot()

TaskSnapshot threadman::TaskHandle::snapshot ( ) const
inline

Consistent snapshot of the task's state.

◆ state()

TaskState threadman::TaskHandle::state ( ) const
inlinenoexcept

◆ valid()

bool threadman::TaskHandle::valid ( ) const
inlinenoexcept

True iff this handle owns a state.


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