|
Lightweight 0.20260617.0
|
#include <ManualExecutor.hpp>
Public Member Functions | |
| ManualExecutor (ManualExecutor const &)=delete | |
| ManualExecutor & | operator= (ManualExecutor const &)=delete |
| ManualExecutor (ManualExecutor &&)=delete | |
| ManualExecutor & | operator= (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 | |
| IExecutor & | operator= (IExecutor const &)=delete |
| IExecutor (IExecutor &&)=delete | |
| IExecutor & | operator= (IExecutor &&)=delete |
Public Member Functions inherited from Lightweight::Async::IResumeScheduler | |
| IResumeScheduler (IResumeScheduler const &)=delete | |
| IResumeScheduler & | operator= (IResumeScheduler const &)=delete |
| IResumeScheduler (IResumeScheduler &&)=delete | |
| IResumeScheduler & | operator= (IResumeScheduler &&)=delete |
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.
|
overridevirtual |
Schedules work to run on the executor. Thread-safe.
| work | The work item to enqueue (consumed). |
Implements Lightweight::Async::IExecutor.
|
overridevirtual |
Schedules handle to be resumed. Thread-safe.
| handle | The coroutine to resume. |
Implements Lightweight::Async::IResumeScheduler.
| bool Lightweight::Async::ManualExecutor::RunOne | ( | ) |
Runs at most one queued work item without blocking.
| std::size_t Lightweight::Async::ManualExecutor::Drain | ( | ) |
Runs all currently-runnable work until the queue is empty, without blocking.
| std::size_t Lightweight::Async::ManualExecutor::PendingCount | ( | ) | const |
|
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.
| Predicate | A callable returning something contextually convertible to bool. |
| predicate | Stop condition, re-checked between work items. |
Definition at line 62 of file ManualExecutor.hpp.