#tokio-task #executor #running #bounded #limit #count #concurrently

rider

bounded executor for tokio; limit the count of tasks running 🚦

3 releases

0.1.2 Mar 13, 2024
0.1.1 Mar 10, 2024
0.1.0 Mar 10, 2024

#328 in Concurrency

Download history 181/week @ 2024-03-06 142/week @ 2024-03-13 31/week @ 2024-03-20 7/week @ 2024-03-27 18/week @ 2024-04-03

62 downloads per month

Custom license

16KB

rider

License Cargo Documentation

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;
}

lib.rs:

The library provides a bounded executor for tokio for a convenient way to run a fixed number of tasks concurrently

See: Rider::new, Rider::spawn and Rider::shutdown

Dependencies

~2–3MB
~46K SLoC