Skip to content

Commit

Permalink
Ch. 17: start in earnest on §2, showing relation to threads
Browse files Browse the repository at this point in the history
Add some listings which I can actually run, with `TODO` paths in them
since I do not know what the numbers will be, since I have not actually
finished with §0 or §1 yet!
  • Loading branch information
chriskrycho committed May 15, 2024
1 parent cb376b3 commit 43d0ee8
Show file tree
Hide file tree
Showing 10 changed files with 1,814 additions and 0 deletions.
540 changes: 540 additions & 0 deletions listings/ch17-async-await/listing-TODO-01/Cargo.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions listings/ch17-async-await/listing-TODO-01/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "async_await"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
trpl = { path = "../../../packages/trpl" }
17 changes: 17 additions & 0 deletions listings/ch17-async-await/listing-TODO-01/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::time::Duration;

fn main() {
trpl::block_on(async {
trpl::spawn_task(async {
for i in 1..10 {
println!("hi number {i} from the first task!");
trpl::sleep(Duration::from_millis(1)).await;
}
});

for i in 1..5 {
println!("hi number {i} from the second task!");
trpl::sleep(Duration::from_millis(1)).await;
}
});
}
Loading

0 comments on commit 43d0ee8

Please sign in to comment.