[−][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:
- The current thread runs a
LocalExecutorand the mainfutureon it. - A thread pool runs an
Executoruntil the mainfuturecompletes.
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; })