Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
uni20::async::IAsyncScheduler Class Referenceabstract

Scheduler interface for initial AsyncTask submission and host-side progress. More...

#include <scheduler.hpp>

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

Classes

struct  WaitRequest
 Readiness predicate and optional targeted wakeup registration for a blocking wait. More...
 

Public Types

using WaitPredicate = std::function< bool()>
 
using WaitWakeup = std::function< void()>
 
using WaitWakeupRegistration = std::function< void(WaitWakeup)>
 

Public Member Functions

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 help_while_waiting (const WaitPredicate &is_ready)
 Allow a scheduler to advance queued work while a thread is blocking.
 
virtual void pause ()=0
 Pause the scheduler.
 
virtual void resume ()=0
 Resume the scheduler.
 
virtual void schedule (AsyncTask &&task)=0
 Schedule a coroutine for its initial execution.
 
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.
 

Detailed Description

Scheduler interface for initial AsyncTask submission and host-side progress.

Member Typedef Documentation

◆ WaitPredicate

using uni20::async::IAsyncScheduler::WaitPredicate = std::function<bool()>

◆ WaitWakeup

using uni20::async::IAsyncScheduler::WaitWakeup = std::function<void()>

◆ WaitWakeupRegistration

Constructor & Destructor Documentation

◆ ~IAsyncScheduler()

uni20::async::IAsyncScheduler::~IAsyncScheduler ( )
overridedefault

Virtual destructor.

Member Function Documentation

◆ execute_batch()

template<class Function >
requires std::invocable<Function&, std::size_t>
void uni20::async::IAsyncScheduler::execute_batch ( std::size_t  size,
Function &&  function 
)
inline

Execute a synchronous batch of independent lightweight work items.

On successful return, the callable has been invoked exactly once for every index in [0, size). Implementations may invoke items concurrently. If an item throws, unfinished items may be cancelled; the exception is rethrown after participating work has joined. The callable is borrowed only for this call.

Batch items are ordinary functions, not coroutine tasks. They may use scheduler APIs, including nested get_wait(), but the batch itself creates no epoch or dependency relationship.

Template Parameters
FunctionCallable accepting one std::size_t index.
Parameters
sizeNumber of work items.
functionWork-item callable.

◆ help_while_waiting()

virtual void uni20::async::IAsyncScheduler::help_while_waiting ( const WaitPredicate &  is_ready)
inlinevirtual

Allow a scheduler to advance queued work while a thread is blocking.

Blocking waits (e.g., Async<T>::get_wait()) call this hook to cooperatively drive progress on the owning scheduler until is_ready() reports completion. The default implementation simply yields the calling thread until the predicate succeeds, which is suitable for schedulers that rely on dedicated worker threads.

Reimplemented in uni20::async::DebugScheduler, and uni20::async::TbbScheduler.

◆ pause()

virtual void uni20::async::IAsyncScheduler::pause ( )
pure virtual

Pause the scheduler.

Tasks can still be scheduled, but they will not start running until resume() is called

Implemented in uni20::async::DebugScheduler, uni20::async::TbbNumaScheduler, and uni20::async::TbbScheduler.

◆ resume()

virtual void uni20::async::IAsyncScheduler::resume ( )
pure virtual

Resume the scheduler.

Tasks scheduled while paused can start running, as can newly scheduled tasks.

Implemented in uni20::async::DebugScheduler, uni20::async::TbbNumaScheduler, and uni20::async::TbbScheduler.

◆ schedule()

virtual void uni20::async::IAsyncScheduler::schedule ( AsyncTask &&  task)
pure virtual

Schedule a coroutine for its initial execution.

Parameters
taskTask to bind to this scheduler and submit.

Implemented in uni20::async::TbbCudaScheduler, uni20::async::TbbScheduler, uni20::async::DebugCudaScheduler, uni20::async::DebugScheduler, and uni20::async::TbbNumaScheduler.

◆ wait_for() [1/2]

virtual void uni20::async::IAsyncScheduler::wait_for ( const WaitPredicate &  is_ready)
inlinevirtual

Block the calling thread until is_ready returns true.

Implementations may override this to provide scheduler-specific waiting semantics (e.g., parking on a condition variable). The default implementation repeatedly invokes help_while_waiting until the predicate succeeds.

Reimplemented in uni20::async::TbbScheduler.

◆ wait_for() [2/2]

virtual void uni20::async::IAsyncScheduler::wait_for ( WaitRequest const &  request)
inlinevirtual

Block until a structured wait request becomes ready.

Parameters
requestReadiness predicate and optional targeted notification registration.

The default implementation preserves compatibility with schedulers that advance work by polling the readiness predicate. Schedulers with a suspend/resume mechanism can override this overload and register the supplied wakeup callback.

Reimplemented in uni20::async::TbbScheduler.


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