system_clock/
system_clock.rs1use std::ops::ControlFlow;
11use std::time::Duration;
12
13use sisyphus::{retry_sync, Constant, PolicyExt, RetryError, SystemClock};
14
15fn main() {
16 let policy = Constant::new(Duration::from_millis(20))
18 .max_elapsed_time(SystemClock, Duration::from_millis(200));
19
20 let mut attempt = 0u32;
21 let result: Result<(), RetryError<u32>> = retry_sync(
22 policy,
23 || {
24 attempt += 1;
25 ControlFlow::Continue(attempt) },
27 std::thread::sleep,
28 );
29
30 match result {
31 Ok(()) => unreachable!(),
32 Err(RetryError::Exhausted(last)) => {
33 println!("real-time budget exhausted after {last} attempts");
34 }
35 }
36}