[−][src]Function futures_ext::top_level_launch
pub fn top_level_launch<F>(future: F) -> Result<F::Item, F::Error> where
F: Future + Send + 'static,
F::Item: Send,
F::Error: Send,
Starts the Tokio runtime using the supplied future to bootstrap the execution.
Similar APIs
This function is equivalent to tokio::run
except that it also returns the
future's resolved value as a Result. Thus it requires F::Item: Send
and
F::Error: Send
.
This function has the same signature as Future::wait
which also goes from
F: Future
-> Result<F::Item, F::Error>
, but wait
requires an ambient
futures runtime to already exist.
Details
This function does the following:
- Start the Tokio runtime using a default configuration.
- Spawn the given future onto the thread pool.
- Block the current thread until the runtime shuts down.
- Send ownership of the future's resolved value back to the caller's thread.
Note that the function will not return immediately once future
has
completed. Instead it waits for the entire runtime to become idle.
Panics
This function panics if called from the context of an executor.