https://github.com/easypost/synchronous-timer-rs
Simple timer/scheduler for Rust
https://github.com/easypost/synchronous-timer-rs
Last synced: 6 months ago
JSON representation
Simple timer/scheduler for Rust
- Host: GitHub
- URL: https://github.com/easypost/synchronous-timer-rs
- Owner: EasyPost
- License: isc
- Created: 2022-06-03T19:11:38.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-06T17:35:37.000Z (over 3 years ago)
- Last Synced: 2025-07-04T15:37:42.661Z (7 months ago)
- Language: Rust
- Size: 11.7 KB
- Stars: 0
- Watchers: 32
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
This is a library, with an API inspired by [timer.rs](https://github.com/Yoric/timer.rs), for scheduling jobs that run synchronously on a background thread.
[](https://github.com/EasyPost/synchronous-timer-rs/actions/workflows/ci.yml)
[](https://docs.rs/synchronous-timer)
[](https://crates.io/crates/synchronous-timer)
Example:
```rust
use std::time::Duration;
use synchronous_timer::Timer;
fn main() {
let mut timer = Timer::new();
timer
.schedule_in(Duration::from_secs(5), || {
println!("I will run on the background thread in 5 seconds")
})
.detach();
timer.schedule_immediately(|| println!("I will run on the background thread right now"));
let handle = timer.schedule_in(Duration::from_secs(1), || println!("I will never run"));
drop(handle);
std::thread::sleep(Duration::from_secs(6));
}
```
This work is licensed under the ISC license, a copy of which can be found in [LICENSE.txt](LICENSE.txt).