Updated 'src/async/all_together.md'.

This commit is contained in:
Hector PENG
2026-04-15 12:44:52 +08:00
parent 68238dec7f
commit 37f854a0f5
5 changed files with 50 additions and 90 deletions

View File

@@ -0,0 +1,7 @@
[package]
name = "mix_parallel_n_concurrency"
version = "0.1.0"
edition = "2024"
[dependencies]
trpl = "0.3.0"

View File

@@ -0,0 +1,18 @@
use std::{thread, time::Duration};
fn main() {
let (tx, mut rx) = trpl::channel();
thread::spawn(move || {
for i in 1..11 {
tx.send(i).unwrap();
thread::sleep(Duration::from_secs(1));
}
});
trpl::block_on(async {
while let Some(message) = rx.recv().await {
println!("{message}");
}
});
}