|
Lightweight 0.20260617.0
|
#include <StrandExecutor.hpp>
Public Member Functions | |
| StrandExecutor (IExecutor &underlying) | |
| StrandExecutor (StrandExecutor const &)=delete | |
| StrandExecutor & | operator= (StrandExecutor const &)=delete |
| StrandExecutor (StrandExecutor &&)=delete | |
| StrandExecutor & | operator= (StrandExecutor &&)=delete |
| void | Post (Work work) override |
| void | Resume (std::coroutine_handle<> handle) override |
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 |
Serializes work over an underlying executor (an Asio-style "strand").
All work posted to a given strand runs one item at a time, in FIFO order, even though the items execute on the underlying executor's worker threads. This guarantees that a single ODBC connection — which is not safe for concurrent use — is touched by only one thread at a time. A strand does not own a thread; it borrows the underlying executor.
The strand's mutable state lives in a heap State held by a std::shared_ptr. Each in-flight drain closure keeps a copy of that pointer, so the state outlives the StrandExecutor wrapper itself until the last drain returns. This makes the strand safe to destroy (or to replace, e.g. via SqlConnection::EnableAsync) while a drain is still running on a worker thread — the closure only ever touches State, never the wrapper.
Definition at line 25 of file StrandExecutor.hpp.
|
explicit |
Constructs a strand layered over underlying.
| underlying | The executor that actually runs the serialized work. |
|
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.