[][src]Function safina::spawn

pub fn spawn(fut: impl Send + Future<Output = ()> + '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.

Uses std::boxed::Box::pin to make the future Unpin. You can use spawn_unpin to avoid this allocation.

Example:

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