Lightweight 0.20260617.0
Loading...
Searching...
No Matches
Lightweight::Async::ManualExecutor Class Referencefinal

#include <ManualExecutor.hpp>

Inheritance diagram for Lightweight::Async::ManualExecutor:
Lightweight::Async::IExecutor Lightweight::Async::IResumeScheduler

Public Member Functions

 ManualExecutor (ManualExecutor const &)=delete
 
ManualExecutoroperator= (ManualExecutor const &)=delete
 
 ManualExecutor (ManualExecutor &&)=delete
 
ManualExecutoroperator= (ManualExecutor &&)=delete
 
void Post (Work work) override
 
void Resume (std::coroutine_handle<> handle) override
 
bool RunOne ()
 
std::size_t Drain ()
 
void Run ()
 Blocks pumping work until Stop is called and the queue has drained.
 
void Stop ()
 Requests Run to return once the queue is empty.
 
std::size_t PendingCount () const
 
template<typename Predicate >
void RunUntil (Predicate predicate)
 
- Public Member Functions inherited from Lightweight::Async::IExecutor
 IExecutor (IExecutor const &)=delete
 
IExecutoroperator= (IExecutor const &)=delete
 
 IExecutor (IExecutor &&)=delete
 
IExecutoroperator= (IExecutor &&)=delete
 
- Public Member Functions inherited from Lightweight::Async::IResumeScheduler
 IResumeScheduler (IResumeScheduler const &)=delete
 
IResumeScheduleroperator= (IResumeScheduler const &)=delete
 
 IResumeScheduler (IResumeScheduler &&)=delete
 
IResumeScheduleroperator= (IResumeScheduler &&)=delete
 

Detailed Description

An executor that runs work only when explicitly pumped by the owning thread.

This is the "app thread" / event-loop resume target for the single-threaded model: blocking ODBC work is offloaded to a ThreadPoolExecutor, and the coroutine's continuation is posted back here so that all user-visible coroutine logic resumes on the one thread that drives this executor (via Run, Drain, RunOne or RunUntil). All members are thread-safe to call; the pumping members (Run / Drain / RunOne / RunUntil) are intended for a single consumer thread.

Definition at line 23 of file ManualExecutor.hpp.

Member Function Documentation

◆ Post()

void Lightweight::Async::ManualExecutor::Post ( Work  work)
overridevirtual

Schedules work to run on the executor. Thread-safe.

Parameters
workThe work item to enqueue (consumed).

Implements Lightweight::Async::IExecutor.

◆ Resume()

void Lightweight::Async::ManualExecutor::Resume ( std::coroutine_handle<>  handle)
overridevirtual

Schedules handle to be resumed. Thread-safe.

Parameters
handleThe coroutine to resume.

Implements Lightweight::Async::IResumeScheduler.

◆ RunOne()

bool Lightweight::Async::ManualExecutor::RunOne ( )

Runs at most one queued work item without blocking.

Returns
true if an item was run, false if the queue was empty.

◆ Drain()

std::size_t Lightweight::Async::ManualExecutor::Drain ( )

Runs all currently-runnable work until the queue is empty, without blocking.

Returns
the number of work items executed.

◆ PendingCount()

std::size_t Lightweight::Async::ManualExecutor::PendingCount ( ) const
Returns
the number of currently-queued work items.

◆ RunUntil()

template<typename Predicate >
void Lightweight::Async::ManualExecutor::RunUntil ( Predicate  predicate)
inline

Pumps work until predicate returns true.

Blocks the calling thread between work items, waking when new work is posted. The predicate must be cheap and must not acquire this executor's internal lock. This is the driver used by SyncWaitPumping for the single-threaded model.

Template Parameters
PredicateA callable returning something contextually convertible to bool.
Parameters
predicateStop condition, re-checked between work items.

Definition at line 62 of file ManualExecutor.hpp.


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