[][src]Function async_runtime::spawn_handle

pub fn spawn_handle<T: Send + 'static>(
    fut: impl Future<Output = T> + Send + 'static
) -> Result<Box<dyn Future<Output = T> + Unpin + Send + 'static>, Error>

Spawn a future and recover the output or just .await it to make sure it's finished. Since different executors return different types, we have to Box the returned future.

Note that if you drop the handle, your future will not be polled.

If on a threadpool and your future panics, the panic will be swallowed.

async-std always returns a JoinHandle. You could call async-std's spawn method directly, knowing that worker threads might not be set up to end further calls to spawn to the async-std executor. Only do this if the spawned future will not call spawn and friends.

Example

Errors