Skip to main content

spawn

Function spawn 

Source
pub async unsafe fn spawn<F: FnOnce() -> i32 + 'static>(
    manager: &'static Manager,
    parent: TaskIdentifier,
    name: &str,
    stack: Stack,
    entry: F,
) -> Result<(JoinHandle<i32>, TaskIdentifier)>
Expand description

Spawn on the calling task’s executor, preserving stack/thread affinity. The manager additionally allocates its existing task pool, metadata and join signal.

§Safety

Same contract as Coroutine::new. The manager must map the current task to its actual executor; registering or moving local Spawners across threads is invalid.