Skip to content

Commit

Permalink
Collect responses from tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
czzrr committed Mar 21, 2024
1 parent ec68a84 commit 2c668c4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tokio/src/sync/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,19 @@ use std::sync::Arc;
/// drop(_permit);
/// // Handle response.
/// // ...
///
/// response
/// });
/// jhs.push(jh);
/// }
/// // Collect responses from tasks.
/// let mut responses = Vec::new();
/// for jh in jhs {
/// jh.await.unwrap();
/// let response = jh.await.unwrap();
/// responses.push(response);
/// }
/// // Process responses.
/// // ...
/// }
/// # async fn send_request(task_id: usize) {
/// # // Send request.
Expand Down

0 comments on commit 2c668c4

Please sign in to comment.