[−][src]Function async_runtime::rt::spawn
pub fn spawn(
fut: impl Future<Output = ()> + 'static + Send
) -> Result<(), RtErr>
Spawn a future to be run on the default executor (set with init or default, depending on juliex feature
,
see documentation for rt::init).
Errors
- When using
RtConfig::Pool
(currently juliex), this method is infallible. - When using
RtConfig::Local
(currently futures 0.3 LocalPool), this method can return a spawn error if the executor has been shut down. See the docs for the futures library. I haven't really found a way to trigger this error. You can call crate::rt::run and spawn again afterwards.
Example
use async_runtime::*; // This will run on the threadpool. For the local pool you must call [rt::init] and [rt::run]. // rt::spawn( async { println!( "async execution" ); });