eve.core.cancellation

EVE Cancellation Support

This module provides a @nogc cancellation mechanism based on explicit cancellation tokens and sources. It allows asynchronous operations to be cancelled mid-flight while ensuring that all resources are cleaned up correctly.

Types 4

enumCancelReason : ubyte

Reason an operation was terminated.

SUCCESSOperation completed normally.
CANCELLEDOperation was cancelled via a CancelToken.
TIMEOUTOperation timed out.
CLOSEDUnderlying resource was closed.
ERRORSystem error.

Shared state for cancellation tracking.

This struct is intended to be used with CancelSource and CancelToken.

Fields
ubyte cancelledAtomic flag for cancellation (0 = false, 1 = true).

Cancellation token — an opaque, @nogc handle passed to async operations.

When the corresponding source is cancelled, the token's isCancelled property will return true.

Fields
private shared(CancelState) * _state
CancelToken(null) invalidSentinel invalid token.
Methods
bool isCancelled() @property const @safe nothrow @nogcCheck if cancellation has been requested.
bool isValid() @property const pure nothrow @nogc @safeCheck if this token is valid.

The owner of a cancellation state.

A source can be used to trigger cancellation and provide tokens to multiple asynchronous operations.

Fields
private CancelState _state
Methods
CancelToken token() @trusted nothrow @nogcGet a cancellation token for this source.
void cancel() @safe nothrow @nogcRequest cancellation.
bool isCancelled() @property const @safe nothrow @nogcCheck if this source has been cancelled.