Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::async::VirtualTimeExecutor Class Reference

#include <virtual_time_executor.hpp>

Inheritance diagram for aria::async::VirtualTimeExecutor:
[legend]

Public Types

using clock = std::chrono::steady_clock
using duration = std::chrono::milliseconds

Public Member Functions

 VirtualTimeExecutor ()=default
aria::SchedulerCaps caps () const noexcept override
 Capabilities: Post (immediate), Delay (deadline-keyed), GraphSafe.
void schedule (std::function< void()> fn) override
 Submit fn for execution "soon". Defines Caps::Post.
void schedule_after (std::chrono::milliseconds delay, std::function< void()> fn) override
 Submit fn for execution after delay.
void post (std::function< void()> fn) override
 IExecutor: schedule "now" — runs at the current virtual time when the next advance_by()/run_until_idle() is called.
void post_after (duration delay, std::function< void()> fn) override
 Schedule to run after delay of virtual time.
duration now () const noexcept
 Current virtual time (since construction).
std::size_t pending () const noexcept
 Number of scheduled tasks not yet fired.
std::size_t advance_by (duration delta)
 Advance virtual time by delta, firing tasks in deadline order.
std::size_t advance_to (duration target)
 Advance to an absolute virtual time target (must be >= now()).
std::size_t run_until_idle ()
 Run everything currently queued without advancing time beyond the last deadline.
void clear () noexcept
 Drop all scheduled tasks without firing them.
Public Member Functions inherited from aria::async::IExecutor
 ~IExecutor () override=default
virtual bool is_safe_graph_executor () const noexcept
 True iff this executor is safe to use as the graph-thread (UI) executor.
virtual bool is_safe_worker_executor () const noexcept
 True iff this executor can host worker tasks.
Public Member Functions inherited from aria::IScheduler
virtual ~IScheduler ()=default
virtual bool is_main_thread () const noexcept
 True iff the calling thread is the scheduler's "main" thread.
Public Member Functions inherited from aria::IDelayedScheduler
 ~IDelayedScheduler () override

Member Typedef Documentation

◆ clock

using aria::async::VirtualTimeExecutor::clock = std::chrono::steady_clock

◆ duration

using aria::async::VirtualTimeExecutor::duration = std::chrono::milliseconds

Constructor & Destructor Documentation

◆ VirtualTimeExecutor()

aria::async::VirtualTimeExecutor::VirtualTimeExecutor ( )
default

Member Function Documentation

◆ caps()

aria::SchedulerCaps aria::async::VirtualTimeExecutor::caps ( ) const
inlinenodiscardoverridevirtualnoexcept

Capabilities: Post (immediate), Delay (deadline-keyed), GraphSafe.

  • WorkerSafe (single-threaded virtual clock — no thread races), Pumpable (advance_by/run_until_idle drive progress; no autonomous threads). Explicit override is required because both IExecutor and IDelayedScheduler provide a caps() of their own and the multiple-inheritance lookup would otherwise be ambiguous.

Reimplemented from aria::async::IExecutor.

◆ schedule()

void aria::async::VirtualTimeExecutor::schedule ( std::function< void()> fn)
inlineoverridevirtual

Submit fn for execution "soon". Defines Caps::Post.

Reimplemented from aria::async::IExecutor.

◆ schedule_after()

void aria::async::VirtualTimeExecutor::schedule_after ( std::chrono::milliseconds delay,
std::function< void()> fn )
inlineoverridevirtual

Submit fn for execution after delay.

Default implementation throws unsupported_capability; implementations that advertise Caps::Delay MUST override.

Reimplemented from aria::IScheduler.

◆ post()

void aria::async::VirtualTimeExecutor::post ( std::function< void()> fn)
inlineoverridevirtual

IExecutor: schedule "now" — runs at the current virtual time when the next advance_by()/run_until_idle() is called.

Implements aria::async::IExecutor.

◆ post_after()

void aria::async::VirtualTimeExecutor::post_after ( duration delay,
std::function< void()> fn )
inlineoverridevirtual

Schedule to run after delay of virtual time.

(Also implements IDelayedScheduler.)

Implements aria::IDelayedScheduler.

◆ now()

duration aria::async::VirtualTimeExecutor::now ( ) const
inlinenodiscardnoexcept

Current virtual time (since construction).

◆ pending()

std::size_t aria::async::VirtualTimeExecutor::pending ( ) const
inlinenodiscardnoexcept

Number of scheduled tasks not yet fired.

◆ advance_by()

std::size_t aria::async::VirtualTimeExecutor::advance_by ( duration delta)
inline

Advance virtual time by delta, firing tasks in deadline order.

Returns the number of tasks fired.

◆ advance_to()

std::size_t aria::async::VirtualTimeExecutor::advance_to ( duration target)
inline

Advance to an absolute virtual time target (must be >= now()).

◆ run_until_idle()

std::size_t aria::async::VirtualTimeExecutor::run_until_idle ( )
inline

Run everything currently queued without advancing time beyond the last deadline.

Useful when you only want to drain "post()" tasks (delay == 0) without simulating a time jump.

◆ clear()

void aria::async::VirtualTimeExecutor::clear ( )
inlinenoexcept

Drop all scheduled tasks without firing them.


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