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

In-process dispatcher: runs queued callables when pump() is invoked (typically from your main loop). More...

#include <dispatcher.hpp>

Inheritance diagram for aria::runtime::SimpleDispatcher:
[legend]

Public Member Functions

 SimpleDispatcher ()
 ~SimpleDispatcher () override
 SimpleDispatcher (const SimpleDispatcher &)=delete
SimpleDispatcheroperator= (const SimpleDispatcher &)=delete
 SimpleDispatcher (SimpleDispatcher &&)=delete
SimpleDispatcheroperator= (SimpleDispatcher &&)=delete
void post (std::function< void()> fn) override
 Schedule the callable to run on the main thread (asynchronously).
void post_delayed (std::chrono::milliseconds delay, std::function< void()> fn) override
 Like post(), but with a delay.
bool is_main_thread () const noexcept override
 Returns true if currently executing on the main thread.
std::size_t pump (std::chrono::milliseconds budget=std::chrono::milliseconds{50})
 Pump pending callables on the creating thread.
void run_one ()
 Block on the creating thread until one callable is available, then run it.
Public Member Functions inherited from aria::runtime::IDispatcher
 ~IDispatcher () override=default
void post_after (std::chrono::milliseconds delay, std::function< void()> fn) override
 IDelayedScheduler adapter — routes to post_delayed.
::aria::SchedulerCaps caps () const noexcept override
 Capability bitmask.
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.
Public Member Functions inherited from aria::IDelayedScheduler
 ~IDelayedScheduler () override
Public Member Functions inherited from aria::IScheduler
virtual ~IScheduler ()=default

Detailed Description

In-process dispatcher: runs queued callables when pump() is invoked (typically from your main loop).

Suitable for console apps and tests.

Constructor & Destructor Documentation

◆ SimpleDispatcher() [1/3]

aria::runtime::SimpleDispatcher::SimpleDispatcher ( )

◆ ~SimpleDispatcher()

aria::runtime::SimpleDispatcher::~SimpleDispatcher ( )
override

◆ SimpleDispatcher() [2/3]

aria::runtime::SimpleDispatcher::SimpleDispatcher ( const SimpleDispatcher & )
delete

◆ SimpleDispatcher() [3/3]

aria::runtime::SimpleDispatcher::SimpleDispatcher ( SimpleDispatcher && )
delete

Member Function Documentation

◆ operator=() [1/2]

SimpleDispatcher & aria::runtime::SimpleDispatcher::operator= ( const SimpleDispatcher & )
delete

◆ operator=() [2/2]

SimpleDispatcher & aria::runtime::SimpleDispatcher::operator= ( SimpleDispatcher && )
delete

◆ post()

void aria::runtime::SimpleDispatcher::post ( std::function< void()> fn)
overridevirtual

Schedule the callable to run on the main thread (asynchronously).

Implements aria::runtime::IDispatcher.

◆ post_delayed()

void aria::runtime::SimpleDispatcher::post_delayed ( std::chrono::milliseconds delay,
std::function< void()> fn )
overridevirtual

Like post(), but with a delay.

Implements aria::runtime::IDispatcher.

◆ is_main_thread()

bool aria::runtime::SimpleDispatcher::is_main_thread ( ) const
nodiscardoverridevirtualnoexcept

Returns true if currently executing on the main thread.

Implements aria::runtime::IDispatcher.

◆ pump()

std::size_t aria::runtime::SimpleDispatcher::pump ( std::chrono::milliseconds budget = std::chrono::milliseconds{50})

Pump pending callables on the creating thread.

Returns the number processed. Throws std::logic_error when called from another thread.

◆ run_one()

void aria::runtime::SimpleDispatcher::run_one ( )

Block on the creating thread until one callable is available, then run it.

Throws std::logic_error when called from another thread.


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