[][src]Function websocket::async::futures::sync::oneshot::spawn

pub fn spawn<F, E>(
    future: F,
    executor: &E
) -> SpawnHandle<<F as Future>::Item, <F as Future>::Error> where
    E: Executor<Execute<F>>,
    F: Future

Spawns a future onto the instance of Executor provided, executor, returning a handle representing the completion of the future.

The SpawnHandle returned is a future that is a proxy for future itself. When future completes on executor then the SpawnHandle will itself be resolved. Internally SpawnHandle contains a oneshot channel and is thus safe to send across threads.

The future will be canceled if the SpawnHandle is dropped. If this is not desired then the SpawnHandle::forget function can be used to continue running the future to completion.

Panics

This function will panic if the instance of Spawn provided is unable to spawn the future provided.

If the provided instance of Spawn does not actually run future to completion, then the returned handle may panic when polled. Typically this is not a problem, though, as most instances of Spawn will run futures to completion.

Note that the returned future will likely panic if the futures provided panics. If a future running on an executor panics that typically means that the executor drops the future, which falls into the above case of not running the future to completion essentially.