558 B
558 B
tokio Notes
The tokio
Async Runtime
tokio
will be the engine in charge of driving Futures to completion
#[tokio::main]
macro is just a builder to help building the runtime. It is basically saying, we want this async function to be run.tokio::spawn(/*async task*/)
will spawn an async task to be run. We can continue executing other code concurrently whiletask
runs in the background. If we need to wait fortask
to complete before proceeding, we can usetask.await
(which#[tokio::test]
will take care for us in the mean time).