[go: up one dir, main page]

[][src]Function smol::run

pub fn run<T>(future: impl Future<Output = T>) -> T

Starts an executor and runs the future on it.

This function runs two executors at the same time:

  1. The current thread runs a LocalExecutor and the main future on it.
  2. A thread pool runs an Executor until the main future completes.

The number of spawned threads matches the number of logical CPU cores on the system.

Examples

use smol::Task;

smol::run(async {
    let task = Task::spawn(async {
        println!("Hello world");
    });
    task.await;
})