spawn

Function spawn 

Source
pub fn spawn<F, S>(future: F, scheduler: S) -> (Runnable, AsyncTask<F::Output>)
where F: Future + Send + 'static, F::Output: Send + 'static, S: Fn(Runnable) + Send + Sync + 'static,
Available on crate feature async-task only.
Expand description

Spawn a future with a custom scheduler using async_task.

This function creates a task that will be scheduled using the provided scheduler function. The scheduler receives a Runnable that should be executed to make progress on the task.

Returns a tuple of (runnable, task) where:

  • runnable should be scheduled immediately to start the task
  • task is an AsyncTask that can be awaited for the result