https://github.com/mrtazz/backofftimer
a simple backoff timer written in rust
https://github.com/mrtazz/backofftimer
Last synced: about 1 year ago
JSON representation
a simple backoff timer written in rust
- Host: GitHub
- URL: https://github.com/mrtazz/backofftimer
- Owner: mrtazz
- License: mit
- Created: 2016-12-17T03:24:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-20T03:36:33.000Z (over 9 years ago)
- Last Synced: 2025-03-21T02:29:06.385Z (over 1 year ago)
- Language: Rust
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# BackoffTimer
[](https://travis-ci.org/mrtazz/BackoffTimer)
[](http://opensource.org/licenses/MIT)
## Overview
BackoffTimer is a rust library that implements different algorithms for
backoff timers.
```rust
use backoff_timer::BackoffTimer;
use backoff_timer::ExponentialBackoffTimer;
/// exponentially back off and wait at most 5 seconds
let mut timer = ExponentialBackoffTimer::new(5);
let mut timer = ExponentialBackoffTimer::new(6);
match timer.wait() {
Ok(time_waited) => assert_eq!(time_waited, 2),
Err(e) => panic!(e),
}
assert_eq!(timer.is_done(), false);
```