|
VLink
2.0.0
A high-performance communication middleware
|
Mutator that mints observer tokens and signals one-shot cancellation. 更多...
#include <cancellation.h>
Public 成员函数 | |
| CancellationSource () | |
| Constructs an uncancelled source with no subscribed callbacks. 更多... | |
| CancellationToken | token () const noexcept |
| Returns a fresh observer token bound to this source. 更多... | |
| bool | is_cancellation_requested () const noexcept |
Returns true once request_cancel has succeeded on this source. 更多... | |
| bool | request_cancel () const |
| Performs the one-shot active -> cancelled transition and fires registered callbacks. 更多... | |
Mutator that mints observer tokens and signals one-shot cancellation.
Holds a refcounted handle to the cancellation state; copies and moves share that state, so any copy can mint tokens or request cancellation against the same one-shot transition. token returns a cheap observer; request_cancel performs the transition exactly once and fires every subscribed callback.
| vlink::CancellationSource::CancellationSource | ( | ) |
Constructs an uncancelled source with no subscribed callbacks.
|
noexcept |
Returns true once request_cancel has succeeded on this source.
true after the one-shot transition has completed. | bool vlink::CancellationSource::request_cancel | ( | ) | const |
Performs the one-shot active -> cancelled transition and fires registered callbacks.
Acquires the internal state mutex, swaps the cancellation flag, releases the mutex, then runs every callback that was attached at the moment of the transition. Exceptions thrown by callbacks are caught and logged.
true when this call performed the transition; false when a previous call had already cancelled the source.
|
noexcept |
Returns a fresh observer token bound to this source.
CancellationToken sharing the source's state.