File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -81,22 +81,22 @@ Works seamlessly with Tokio:
8181``` rust
8282use std :: {iter :: repeat_n, time :: Duration };
8383
84- use compact_waitgroup :: WaitGroup ;
84+ use compact_waitgroup :: { WaitGroup , WithWorkerHandle } ;
8585use tokio :: time :: sleep;
8686
8787#[tokio:: main]
8888async 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
You can’t perform that action at this time.
0 commit comments