pub fn spawn_blocking<F, T>(&self, task: F) -> JoinHandle<T>
    where
        F: FnOnce() -> T + Send + 'static,
        T: Send + 'static,
    {
        let inner = match &self.inner {
            #[cfg(feature = "tokio_executor")]
            TokioHandle(handle) => {
                JoinHandleInner::<T>::Tokio(Some(handle.spawn_blocking(task)))
            },
            #[cfg(feature = "async_std_executor")]
            AsyncStdHandle => {
                JoinHandleInner::<T>::AsyncStd(Some(async_std::task::spawn_blocking(task)))
            },
            #[cfg(feature = "smol_executor")]
            SmolHandle(executor) => {
                JoinHandleInner::<T>::Smol(Some(executor.spawn(blocking::unblock( || task() ))))
            },
            #[cfg(feature = "futures_executor")]
            FuturesHandle(executor) => {
                use futures::future::FutureExt;
                let (future, handle) = (async { task()}).remote_handle();
                executor.spawn_ok(future); // TODO Maybe use blocking::unblock to make it use a threadpool instead of blocking the main one
                JoinHandleInner::<T>::RemoteHandle(Some(handle))
            },
            #[cfg(feature = "wasm_bindgen_executor")]
            WasmBindgenHandle => {
                use futures::future::FutureExt;
                let (future, handle) = (async { task() }).remote_handle();
                wasm_bindgen_futures::spawn_local(future);
                JoinHandleInner::<T>::RemoteHandle(Some(handle))
            }
        };

        JoinHandle{inner}
    }
/// Runs the provided closure, and when possible, it does it in a way that doesn't block concurrent tasks.
Runs the provided closure, and when possible, it does it in a way that doesn't block concurrent tasks.
Runs the provided closure and when possible it does it in a way that doesn ' t block concurrent tasks .
pub fn spawn_blocking<F, T>(&self, task: F) -> JoinHandle<T>
    where
        F: FnOnce() -> T + Send + 'static,
        T: Send + 'static,
    {
        let inner = match &self.inner {
            #[cfg(feature = "tokio_executor")]
            TokioHandle(handle) => {
                JoinHandleInner::<T>::Tokio(Some(handle.spawn_blocking(task)))
            },
            #[cfg(feature = "async_std_executor")]
            AsyncStdHandle => {
                JoinHandleInner::<T>::AsyncStd(Some(async_std::task::spawn_blocking(task)))
            },
            #[cfg(feature = "smol_executor")]
            SmolHandle(executor) => {
                JoinHandleInner::<T>::Smol(Some(executor.spawn(blocking::unblock( || task() ))))
            },
            #[cfg(feature = "futures_executor")]
            FuturesHandle(executor) => {
                use futures::future::FutureExt;
                let (future, handle) = (async { task()}).remote_handle();
                executor.spawn_ok(future); // TODO Maybe use blocking::unblock to make it use a threadpool instead of blocking the main one
                JoinHandleInner::<T>::RemoteHandle(Some(handle))
            },
            #[cfg(feature = "wasm_bindgen_executor")]
            WasmBindgenHandle => {
                use futures::future::FutureExt;
                let (future, handle) = (async { task() }).remote_handle();
                wasm_bindgen_futures::spawn_local(future);
                JoinHandleInner::<T>::RemoteHandle(Some(handle))
            }
        };
        JoinHandle{inner}
    }
pub fn spawn_blocking < F , T > ( & self , task : F ) -> JoinHandle < T > where F : FnOnce ( ) -> T + Send + ' static , T : Send + ' static , { let inner = match & self . inner { # [ cfg ( feature " " ) ] TokioHandle ( handle ) => { JoinHandleInner :: < T > :: Tokio ( Some ( handle . spawn_blocking ( task ) ) ) } , # [ cfg ( feature " " ) ] AsyncStdHandle => { JoinHandleInner :: < T > :: AsyncStd ( Some ( async_std :: task :: spawn_blocking ( task ) ) ) } , # [ cfg ( feature " " ) ] SmolHandle ( executor ) => { JoinHandleInner :: < T > :: Smol ( Some ( executor . spawn ( blocking :: unblock ( | | task ( ) ) ) ) ) } , # [ cfg ( feature " " ) ] FuturesHandle ( executor ) => { use futures :: future :: FutureExt ; let ( future , handle ) = ( async { task ( ) } ) . remote_handle ( ) ; executor . spawn_ok ( future ) ; // TODO Maybe use blocking::unblock to make it use a threadpool instead of blocking the main one JoinHandleInner :: < T > :: RemoteHandle ( Some ( handle ) ) } , # [ cfg ( feature " " ) ] WasmBindgenHandle => { use futures :: future :: FutureExt ; let ( future , handle ) = ( async { task ( ) } ) . remote_handle ( ) ; wasm_bindgen_futures :: spawn_local ( future ) ; JoinHandleInner :: < T > :: RemoteHandle ( Some ( handle ) ) } } ; JoinHandle { inner } }
Runs the provided closure, and when possible, it does it in a way that doesn't block concurrent tasks.
Runs the provided closure and when possible it does it in a way that doesn ' t block concurrent tasks .
&self
task
F