|
VLink
2.0.0
A high-performance communication middleware
|
Cooperative one-shot cancellation primitives shared by VLink async building blocks. 更多...
类 | |
| class | vlink::CancellationRegistration |
| Move-only RAII handle that represents one subscribed cancellation callback. 更多... | |
| class | vlink::CancellationToken |
Lightweight observer of a CancellationSource shared across worker threads. 更多... | |
| class | vlink::CancellationSource |
| Mutator that mints observer tokens and signals one-shot cancellation. 更多... | |
命名空间 | |
| vlink | |
Cooperative one-shot cancellation primitives shared by VLink async building blocks.
Cancellation is split into a writable CancellationSource owned by the work producer, one or more read-only CancellationToken observers held by workers, and per-callback CancellationRegistration handles used to unsubscribe pending callbacks. All three share a refcounted internal state allocated on the producer side.
| Type | Role | Copy / Move |
|---|---|---|
CancellationSource | Mutator; signals cancellation | Implicit (refcount) |
CancellationToken | Observer; poll / throw / subscribe | Copyable |
CancellationRegistration | RAII slot for one subscribed callback | Move-only |
* +------------+ request_cancel() +---------------+ no-ops on further calls * | active | --------------------> | cancelled | -------------------------+ * | (default) | | (terminal) | | * +------------+ +---------------+ | * ^ ^ ^ | * | | is_cancellation_requested()=false | * | | throw_if_cancellation_requested()=no-op | * | | v * | +-- new tokens via token() share the same state ------------------ read-only * | * +------ register_callback() inserts a slot; fires synchronously on transition *
Cancellation is one-shot. After the first successful request_cancel the state is terminal; subsequent requests return false and never re-invoke callbacks. The cancelled type re-exported as vlink::Exception::OperationCancelled is the canonical thrown type at structured cancellation points.