Skip to content

Commit

Permalink
fix deadlock on M1 macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrunji0408 committed Nov 30, 2021
1 parent 047ea7d commit 5c77e68
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion madsim-sim/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ impl TimeRuntime {
/// Advance the time and fire timers.
pub fn advance(&self) -> bool {
let mut timer = self.handle.timer.lock().unwrap();
if let Some(time) = timer.next() {
if let Some(mut time) = timer.next() {
// WARN: in some platform such as M1 macOS,
// let t0: Instant;
// let t1: Instant;
// t0 + (t1 - t0) < t1 !!
// we should add eps to make sure 'now >= deadline' and avoid deadlock
time += Duration::from_nanos(50);

timer.expire(time);
self.handle.clock.set_elapsed(time);
true
Expand Down

0 comments on commit 5c77e68

Please sign in to comment.