[][src]Function safina_executor::spawn

pub fn spawn(fut: impl Future<Output = ()> + Send + Unpin + 'static)

Adds a task that will execute fut. The task runs on any available worker thread.

If no worker threads are running, the new task will not execute. The task will execute once a worker thread begins work. See increase_threads_to and work.

Returns immediately.

This runtime does not unsafely convert your futures to Pin. You must wrap your future in Box::pin.

Example:

safina_executor::increase_threads_to(1);
safina_executor::spawn(Box::pin(async move {
    an_async_fn().await.unwrap();
}));