run_every 0.1.0

Run some code up to once per specified duration
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 1 items with examples
  • Size
  • Source code size: 41.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Riateche/run_every
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Riateche

run_every

Docs Crates.io License

Run some code up to once per specified duration.

Example:

use run_every::run_every;

for _ in 0..1000 {
    let result = do_something();
    if let Err(error) = result {
        run_every!(Duration::from_secs(10), println!("something failed: {error:?}"));
    }
}

A block of code can also be used:

run_every!(Duration::from_secs(10), {
    println!("error!");
    println!("retrying...");
});

The implementation uses a combination of a global mutex and thread local storage to reduce contention.