61 [[nodiscard]] explicit operator
bool() const noexcept {
71 : state_(
std::move(
state)), id_(
id) {}
73 std::shared_ptr<detail::CancelStateBase> state_;
74 std::uint64_t id_ = 0;
85 return state_ &&
state_->cancelled.load(std::memory_order_acquire);
148 return token_.is_cancelled();
RAII registration returned by CancelToken::register_callback.
Definition cancel.hpp:50
void reset() noexcept
Unregister now. Idempotent.
friend class CancelToken
Definition cancel.hpp:69
CancelRegistration() noexcept=default
Move-only owner of a cancellation state.
Definition cancel.hpp:126
CancelSource(const CancelSource &)=delete
bool cancel() noexcept
Signal cancellation.
bool is_cancelled() const noexcept
Definition cancel.hpp:147
CancelSource & operator=(CancelSource &&other) noexcept
Cancels the state this source currently owns, then takes over other.
CancelSource(CancelSource &&other) noexcept=default
CancelToken token() const noexcept
Observer for this source. Tokens remain valid after the source dies.
Definition cancel.hpp:138
CancelSource & operator=(const CancelSource &)=delete
bool is_cancelled() const noexcept
True once the owning source has been cancelled.
Definition cancel.hpp:84
bool shares(const CancelToken &other) const noexcept
True if both tokens observe the same underlying source.
Definition cancel.hpp:105
detail::CancelStateBase State
Definition cancel.hpp:110
static bool request_cancel(const std::shared_ptr< State > &state) noexcept
Mark the state cancelled, wake waiters, run callbacks.
bool can_be_cancelled() const noexcept
True if this token can ever become cancelled (it is bound to a source).
Definition cancel.hpp:89
static std::shared_ptr< State > make_state()
CancelRegistration register_callback(CancelCallback fn) const
Run fn when the token is cancelled.
friend class CancelSource
Definition cancel.hpp:120
std::shared_ptr< State > state_
Definition cancel.hpp:118
CancelToken(std::shared_ptr< State > state) noexcept
Definition cancel.hpp:111
CancelToken() noexcept=default
A token that can never be cancelled.
bool wait_for_cancellation(std::chrono::nanoseconds timeout) const
Block until cancelled or timeout elapses.
void cancel() noexcept
Definition cancel.hpp:165
Definition generated_event_source.hpp:33
std::function< void()> CancelCallback
Callback run when a token is cancelled.
Definition cancel.hpp:42
@ other
Definition udev_monitor.hpp:26
SequencerStateChannel is the audio-safe transport for a plugin's structured NON-parameter state: the ...
Definition audio_device_manager.hpp:48
Public part of the shared state so is_cancelled() can inline to one load.
Definition cancel.hpp:33
std::atomic< bool > cancelled
Definition cancel.hpp:34
virtual ~CancelStateBase()=default