throttle2

Crates.iothrottle2
lib.rsthrottle2
version0.1.1
sourcesrc
created_at2022-03-05 13:00:59.321214
updated_at2022-03-05 13:18:50.502904
descriptionA simple threadsafe throttle (rate limiter) that maintains fixed time intervals between ticks
homepage
repositoryhttps://github.com/Holy-Raccoon/throttle2.git
max_upload_size
id544002
size13,697
Roman Kuchma (Roman-Kuchma)

documentation

README

Cargo Build & Test

A simple threadsafe throttle (rate limiter) that maintains fixed time intervals between ticks.

Usage

use throttle2::Throttle;
use std::time::{Duration, SystemTime};

fn main() {
    let throttle = Throttle::from_cooldown(Duration::from_secs(10));

    println!("Hello world!");
    throttle.tick();
    println!("Hello again 10 seconds later");
    throttle.tick();
    println!("Hello again 10 more seconds later");
}

See [Throttle] documentation and the tests for more examples

Commit count: 2

cargo fmt