# run_every
[](https://docs.rs/run_every/latest/run_every/)
[](https://crates.io/crates/run_every)
[](https://github.com/Riateche/run_every#license)
Run some code up to once per specified duration.
Example:
```rust
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:
```rust
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.