Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
uni20::async::DebugScheduler Class Reference

Single-threaded scheduler with configurable runnable-batch ordering. More...

#include <debug_scheduler.hpp>

Inheritance diagram for uni20::async::DebugScheduler:
[legend]
Collaboration diagram for uni20::async::DebugScheduler:
[legend]

Public Member Functions

bool can_run () const noexcept
 Reports whether at least one runnable task exists.
 
 DebugScheduler (DebugSchedulerOptions options={})
 Default-construct an empty scheduler.
 
bool done () const noexcept
 Check whether the runnable queue is empty.
 
void help_while_waiting (const WaitPredicate &is_ready) override
 Drives one runnable task while waiting for readiness.
 
DebugSchedulerOptions const & options () const noexcept
 Return the scheduler's immutable ordering configuration.
 
void pause () override
 Block the scheduler from running.
 
void resume () override
 Unblock the scheduler.
 
void run ()
 Run one batch of scheduled coroutines in the configured order.
 
void run_all ()
 Run until no runnable tasks remain.
 
void schedule (AsyncTask &&task) override
 Enqueue a task for later run.
 
 ~DebugScheduler ()
 Destructor.
 
- Public Member Functions inherited from uni20::async::IAsyncScheduler
template<class Function >
requires std::invocable<Function&, std::size_t>
void execute_batch (std::size_t size, Function &&function)
 Execute a synchronous batch of independent lightweight work items.
 
virtual void wait_for (const WaitPredicate &is_ready)
 Block the calling thread until is_ready returns true.
 
virtual void wait_for (WaitRequest const &request)
 Block until a structured wait request becomes ready.
 
 ~IAsyncScheduler () override=default
 Virtual destructor.
 
- Public Member Functions inherited from uni20::async::IScheduler
virtual ~IScheduler ()=default
 Virtual destructor.
 

Protected Member Functions

void enqueue_task (BasicTask &&task)
 Add one already-bound task to the runnable queue.
 
virtual void resume_task (BasicTask &task)
 Resume one queued task in the execution context selected by this scheduler.
 

Additional Inherited Members

- Public Types inherited from uni20::async::IAsyncScheduler
using WaitPredicate = std::function< bool()>
 
using WaitWakeup = std::function< void()>
 
using WaitWakeupRegistration = std::function< void(WaitWakeup)>
 

Detailed Description

Single-threaded scheduler with configurable runnable-batch ordering.

Constructor & Destructor Documentation

◆ DebugScheduler()

uni20::async::DebugScheduler::DebugScheduler ( DebugSchedulerOptions  options = {})
inlineexplicit

Default-construct an empty scheduler.

◆ ~DebugScheduler()

uni20::async::DebugScheduler::~DebugScheduler ( )
inline

Destructor.

Member Function Documentation

◆ can_run()

bool uni20::async::DebugScheduler::can_run ( ) const
inlinenoexcept

Reports whether at least one runnable task exists.

Returns
true when the scheduler is not paused and has queued tasks.

◆ done()

bool uni20::async::DebugScheduler::done ( ) const
inlinenoexcept

Check whether the runnable queue is empty.

Returns
true if the scheduler has no queued tasks.

◆ enqueue_task()

void uni20::async::DebugScheduler::enqueue_task ( BasicTask &&  task)
inlineprotected

Add one already-bound task to the runnable queue.

◆ help_while_waiting()

void uni20::async::DebugScheduler::help_while_waiting ( const WaitPredicate &  is_ready)
inlineoverridevirtual

Drives one runnable task while waiting for readiness.

Parameters
is_readyPredicate that reports target readiness.

Reimplemented from uni20::async::IAsyncScheduler.

◆ options()

DebugSchedulerOptions const & uni20::async::DebugScheduler::options ( ) const
inlinenoexcept

Return the scheduler's immutable ordering configuration.

◆ pause()

void uni20::async::DebugScheduler::pause ( )
inlineoverridevirtual

Block the scheduler from running.

Note
This turns run() and run_all() into no-operation;

Implements uni20::async::IAsyncScheduler.

◆ resume()

void uni20::async::DebugScheduler::resume ( )
inlineoverridevirtual

Unblock the scheduler.

Implements uni20::async::IAsyncScheduler.

◆ resume_task()

virtual void uni20::async::DebugScheduler::resume_task ( BasicTask &  task)
inlineprotectedvirtual

Resume one queued task in the execution context selected by this scheduler.

◆ run()

void uni20::async::DebugScheduler::run ( )
inline

Run one batch of scheduled coroutines in the configured order.

◆ run_all()

void uni20::async::DebugScheduler::run_all ( )
inline

Run until no runnable tasks remain.

◆ schedule()

void uni20::async::DebugScheduler::schedule ( AsyncTask &&  task)
inlineoverridevirtual

Enqueue a task for later run.

Parameters
taskAn AsyncTask bound to this scheduler.

Implements uni20::async::IAsyncScheduler.


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