CancellationToken

A shared, mutable cancellation flag for one in-flight request. The server hands the same token to the request's RequestContext (so the handler can poll ctx.isCancelled) and to its in-flight registry (so an inbound notifications/cancelled for the matching request id can flip it). It is a class so the flag is observed across the two tasks that a Streamable HTTP transport runs the request and its cancellation on. See basic/utilities/cancellation: a receiver "SHOULD: Stop processing the cancelled request, Free associated resources, Not send a response".

@safe final
class CancellationToken {}

Members

Functions

cancel
void cancel()

Mark the request cancelled. Idempotent.

cancelled
bool cancelled()

Whether a cancellation has been requested for this token's request.