spawn

Function spawn 

Source
pub fn spawn<Fut>(future: Fut) -> Task<Fut::Output>
where Fut: Future + Send + 'static, Fut::Output: Send,
Expand description

Creates a new task with default priority.

This is the primary function for spawning async tasks. The task will be executed with default priority using platform-native scheduling.

§Arguments

  • future - The future to execute asynchronously

§Returns

A Task handle that can be awaited to retrieve the result

§Examples

use native_executor::spawn;

let task = spawn(async {
    // Your async work here
    42
});