pub trait CancellableExtManual {
    fn connect_cancelled<F: FnOnce(&Self) + Send + 'static>(
        &self,
        callback: F
    ) -> Option<CancelledHandlerId>; fn connect_cancelled_local<F: FnOnce(&Self) + 'static>(
        &self,
        callback: F
    ) -> Option<CancelledHandlerId>; fn disconnect_cancelled(&self, id: CancelledHandlerId); fn future(
        &self
    ) -> Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>; }

Required Methods

Convenience function to connect to the signal::Cancellable::cancelled signal. Also handles the race condition that may happen if the cancellable is cancelled right before connecting. If the operation is cancelled from another thread, callback will be called in the thread that cancelled the operation, not the thread that is running the operation. This may be the main thread, so the callback should not do something that can block.

callback is called at most once, either directly at the time of the connect if self is already cancelled, or when self is cancelled in some thread.

Since GLib 2.40, the lock protecting self is not held when callback is invoked. This lifts a restriction in place for earlier GLib versions which now makes it easier to write cleanup code that unconditionally invokes e.g. CancellableExt::cancel().

Returns

The id of the signal handler or None if self has already been cancelled.

Local variant of Self::connect_cancelled.

Disconnects a handler from a cancellable instance. Additionally, in the event that a signal handler is currently running, this call will block until the handler has finished. Calling this function from a callback registered with Self::connect_cancelled will therefore result in a deadlock.

This avoids a race condition where a thread cancels at the same time as the cancellable operation is finished and the signal handler is removed.

Returns a Future that completes when the cancellable becomes cancelled. Completes immediately if the cancellable is already cancelled.

Implementors