[][src]Function smol::run

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

Starts a thread-local and a multi-threaded executor and then runs the future.

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, but it can be overriden by setting the SMOL_THREADS environment variable.

Examples

use smol::Task;

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