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

Creates a new task to execute fut and schedules it for immediate execution.

Returns immediately.

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

Panics

Panics if the caller is not running on an Executor.

Example

let executor = safina_executor::Executor::default();
executor.spawn(async move {
    safina_executor::spawn(async move {
        an_async_fn().await.unwrap();
    });
});