[][src]Function async_runtime::rt::spawn_local

pub fn spawn_local(fut: impl Future<Output = ()> + 'static) -> Result<(), RtErr>

Spawn a future to be run on the LocalPool (current thread). This will return an error if the current executor is the threadpool.

Does exactly the same as spawn, but does not require the future to be Send. If your future is Send, you can just use spawn. It will always spawn on the default executor.

Errors

  • When using RtConfig::Pool (currently juliex), this method will return a RtErrKind::Spawn. Since the signature doesn't require Send on the future, it can never be sent on a threadpool.
  • 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 rt::run and spawn again afterwards.