Rust throttle_timer

Simple Rust library to throttle events and record event stats

Build Status Coverage Status

Docs

Install Cargo.toml

throttle-timer = "0.0.6"

Example use

```rust use std::time::Duration; use throttle_timer::ThrottleTimer;

let mut throttledfn = ThrottleTimer::new(Duration::fromsecs(10u64), &"throttledfn"); let mut val = 0_u8;

// timers always run when no previous runs throttledfn.dorun(&mut || val += 1); for _ in 0..100 { // timer will not run as 10 secs has not passed // do run will return false throttledfn.dorun(&mut || val += 1); }

throttledfn.printstats(); // throttled_fn called 0/sec, total calls 1, has been running for 10us

asserteq!(throttledfn.totalcalls(), &1); asserteq!(val, 1_u8); ```