VLink  2.0.0
A high-performance communication middleware
vlink::Schedule::Status Class Reference

RAII handle returned by exec_task() when the wrapped callback returns void. More...

#include <schedule.h>

Inheritance diagram for vlink::Schedule::Status:
Collaboration diagram for vlink::Schedule::Status:

Classes

struct  Impl
 

Public Member Functions

 Status ()
 Constructs a fresh handle backed by a newly allocated task state. More...
 
 ~Status ()
 Destroys the handle reference, committing the configuration so the task may dispatch. More...
 
 Status (const Status &)=delete
 
Statusoperator= (const Status &)=delete
 
 Status (Status &&status) noexcept
 Move-constructs from status, transferring its task state. More...
 
Statusoperator= (Status &&status) noexcept
 Move-assigns from status, transferring its task state. More...
 
void set_valid (bool valid)
 Marks whether the handle's underlying task was successfully posted. More...
 
bool is_valid () const
 Reports whether the wrapped task was successfully posted. More...
 
bool dispatch ()
 Commits the configuration immediately and reports whether the task was posted. More...
 
Statuson_schedule_timeout (Callback &&callback)
 Installs the callback fired when the task missed its scheduling deadline. More...
 
Statuson_execution_timeout (Callback &&callback)
 Installs the callback fired when a chained callback exceeds execution_timeout_ms. More...
 
Statuson_catch (CatchCallback &&callback)
 Installs the callback fired when the task throws a std::exception. More...
 

Protected Member Functions

void commit () noexcept
 Runs the installed launcher exactly once, posting the wrapped task to its dispatcher. More...
 

Protected Attributes

friend Schedule
 
friend MessageLoop
 
std::shared_ptr< Implimpl_
 
Callback launcher_
 
bool committed_ {false}
 

Detailed Description

RAII handle returned by exec_task() when the wrapped callback returns void.

Holds a shared reference to the underlying task state. Continuation callbacks may be attached in any order before the configuration is committed; the wrapped task is not dispatched until commit, which happens when the originating handle is destroyed (i.e. the end of the fluent expression) or when dispatch() is called explicitly. Every callback attached before commit is therefore guaranteed to be registered before the task runs; attachments after commit are ignored. Committing does not cancel the task; it posts it.

Constructor & Destructor Documentation

◆ Status() [1/3]

vlink::Schedule::Status::Status ( )

Constructs a fresh handle backed by a newly allocated task state.

◆ ~Status()

vlink::Schedule::Status::~Status ( )

Destroys the handle reference, committing the configuration so the task may dispatch.

Commits the pending configuration: once the originating handle is gone no further continuation callbacks can be attached, so the dispatcher is released to run the task with the full callback chain in place. Does not cancel the task.

◆ Status() [2/3]

vlink::Schedule::Status::Status ( const Status )
delete

◆ Status() [3/3]

vlink::Schedule::Status::Status ( Status &&  status)
noexcept

Move-constructs from status, transferring its task state.

Parameters
statusSource handle to move from.

Member Function Documentation

◆ commit()

void vlink::Schedule::Status::commit ( )
protectednoexcept

Runs the installed launcher exactly once, posting the wrapped task to its dispatcher.

Posting is deferred until the handle is committed so every fluent continuation is registered before the task is enqueued. The launcher lives in the handle (not the shared state), so the post payload is released with the handle and forms no reference cycle. Idempotent and safe on a moved-from handle.

◆ dispatch()

bool vlink::Schedule::Status::dispatch ( )

Commits the configuration immediately and reports whether the task was posted.

The task is otherwise posted when the handle is destroyed. A caller that stores the handle instead of consuming it inline calls dispatch() to post it now and learn the result synchronously. Attach all continuations first; idempotent with the destructor.

Returns
true when the task was accepted by its dispatcher.

◆ is_valid()

bool vlink::Schedule::Status::is_valid ( ) const

Reports whether the wrapped task was successfully posted.

Returns
true when the handle refers to a queued task.

◆ on_catch()

Status& vlink::Schedule::Status::on_catch ( CatchCallback &&  callback)

Installs the callback fired when the task throws a std::exception.

Only std::exception-derived failures are caught; other exception types are allowed to propagate. Only one catch callback may be registered.

Parameters
callbackHook receiving the caught exception.
Returns
Reference to *this for fluent chaining.

◆ on_execution_timeout()

Status& vlink::Schedule::Status::on_execution_timeout ( Callback &&  callback)

Installs the callback fired when a chained callback exceeds execution_timeout_ms.

Triggered after each callback in the chain returns. Only one execution-timeout callback may be registered; late registrations are dropped. Does not interrupt a running callback.

Parameters
callbackHook invoked on the dispatcher thread.
Returns
Reference to *this for fluent chaining.

◆ on_schedule_timeout()

Status& vlink::Schedule::Status::on_schedule_timeout ( Callback &&  callback)

Installs the callback fired when the task missed its scheduling deadline.

Triggered once when the task is dequeued and the elapsed time since posting exceeds delay_ms + schedule_timeout_ms. Only one schedule-timeout callback may be registered; late registrations are dropped.

Parameters
callbackHook invoked on the dispatcher thread.
Returns
Reference to *this for fluent chaining.

◆ operator=() [1/2]

Status& vlink::Schedule::Status::operator= ( const Status )
delete

◆ operator=() [2/2]

Status& vlink::Schedule::Status::operator= ( Status &&  status)
noexcept

Move-assigns from status, transferring its task state.

Parameters
statusSource handle to move from.
Returns
Reference to *this.

◆ set_valid()

void vlink::Schedule::Status::set_valid ( bool  valid)

Marks whether the handle's underlying task was successfully posted.

Parameters
validtrue once the task is queued.

Member Data Documentation

◆ committed_

bool vlink::Schedule::Status::committed_ {false}
protected

◆ impl_

std::shared_ptr<Impl> vlink::Schedule::Status::impl_
protected

◆ launcher_

Callback vlink::Schedule::Status::launcher_
protected

◆ MessageLoop

friend vlink::Schedule::Status::MessageLoop
protected

◆ Schedule

friend vlink::Schedule::Status::Schedule
protected

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