| Crates.io | rider |
| lib.rs | rider |
| version | 0.1.2 |
| created_at | 2024-03-10 21:18:54.571334+00 |
| updated_at | 2024-03-13 18:02:58.956467+00 |
| description | bounded executor for tokio; limit the count of tasks running 🚦 |
| homepage | |
| repository | https://github.com/redcloudvg/rider |
| max_upload_size | |
| id | 1168964 |
| size | 42,133 |
bounded executor for tokio; limit the count of tasks running
use rider::{Rider, RiderError};
#[tokio::main]
async fn main() -> Result<(), RiderError> {
// create an executor that allows at most 10 task running concurrently
let rider = Rider::new(10);
for index in 0..10000 {
rider
.spawn(async move {
println!("{}", index);
})
.await?; // Suspends until task is spawned
}
// Deny further tasks and join remaining tasks
rider.shutdown().await;
}