Skip to content

Commit 478f573

Browse files
committed
misc(docs): update readme
1 parent c5b7875 commit 478f573

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@ Works seamlessly with Tokio:
8181
```rust
8282
use std::{iter::repeat_n, time::Duration};
8383

84-
use compact_waitgroup::WaitGroup;
84+
use compact_waitgroup::{WaitGroup, WithWorkerHandle};
8585
use tokio::time::sleep;
8686

8787
#[tokio::main]
8888
async fn main() {
8989
let (wg, base_handle) = WaitGroup::new();
9090

9191
for (i, handle) in repeat_n(base_handle, 8).enumerate() {
92-
tokio::spawn(async move {
92+
let task = async move {
9393
println!("Task {i} started");
9494
// Long-running task...
9595
sleep(Duration::from_secs(1)).await;
9696
println!("Task {i} finished");
97-
// Handle is dropped here, signaling completion
98-
handle.done();
99-
});
97+
}
98+
.with_worker_handle(handle);
99+
tokio::spawn(task);
100100
}
101101

102102
// Wait for the task to complete

0 commit comments

Comments
 (0)