Lightweight 0.20260617.0
Loading...
Searching...
No Matches
CancellationToken.hpp File Reference
#include <stdexcept>

Go to the source code of this file.

Classes

class  Lightweight::Async::OperationCancelledError
 

Detailed Description

Cooperative cancellation for the async layer is expressed with the standard std::stop_token.

Async methods accept an optional std::stop_token (defaulted to {}). A default-constructed token has no associated stop-state — it is non-cancellable (stop_requested() and stop_possible() are always false) and allocates nothing, the cheap default for callers that do not pass one. To cancel, a caller holds a std::stop_source, passes source.get_token() where supported, and calls source.request_stop().

Cancellation is honored cooperatively and only before dispatch: the offload runtime checks stop_requested() before posting a step to the worker and, if set, completes it with Lightweight::Async::OperationCancelledError without ever occupying a worker. Once a step has begun running, the in-flight blocking ODBC call is not interrupted (there is no SQLCancel integration yet), so a request that arrives after dispatch only takes effect on the next not-yet-dispatched step.

Definition in file CancellationToken.hpp.