spawn_blocking_cancellable

Function spawn_blocking_cancellable 

Source
pub fn spawn_blocking_cancellable<F, R>(f: F) -> JoinHandle<R>
where F: FnOnce(&Cancellable) -> R + Send + 'static, R: Send + 'static,
Expand description

Wrapper for [tokio::task::spawn_blocking] which provides a [gio::Cancellable] that will be triggered on drop.

This function should be used in a Rust/tokio native async fn, but that want to invoke GLib style blocking APIs that use GCancellable. The cancellable will be triggered when this future is dropped, which helps bound thread usage.

This is in a sense the inverse of run_with_cancellable.