Skip to content

Commit

Permalink
fixed overflow with negative durations occurring
Browse files Browse the repository at this point in the history
  • Loading branch information
localthomas committed Nov 10, 2024
1 parent 93fc71d commit 2c96c47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fn looping<T: FnMut() -> Result<()>>(
let start = time::Instant::now();
function()?;
// measure time and then sleep exact so long that the interval is met
thread::sleep(interval - start.elapsed());
thread::sleep(interval.saturating_sub(start.elapsed()));
}
Ok(())
}
Expand Down

0 comments on commit 2c96c47

Please sign in to comment.