[−][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:
- The current thread runs a
LocalExecutor
and the mainfuture
on it. - A thread pool runs an
Executor
until the mainfuture
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; })