-
-
Save bltavares/cbddd771a2325c4cb15f1b8bc3f1d61c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use async_std::task; | |
fn main() { | |
task::block_on(async move { | |
println!("outer"); | |
task::spawn(async move { | |
println!("inner 1"); | |
}); | |
task::spawn(async move { | |
task::sleep(std::time::Duration::from_secs(1)).await; | |
println!("inner 2"); | |
}) | |
.await; // without this, will finish the main block before the tasks are executed | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "async-internal-spawn" | |
version = "0.1.0" | |
authors = ["Ryan James Spencer <[email protected]>"] | |
edition = "2018" | |
[dependencies.async-std] | |
version = '1.6.2' | |
features = ['unstable'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment