In deterministic executor, ensure fake timers are ordered by wake time
Previously, advancing the clock would fail to wake a timer that was set *after* another time whose wake time had not yet arrived.
This commit is contained in:
parent
8411d886ac
commit
4508d94a3e
1 changed files with 6 additions and 1 deletions
|
@ -325,7 +325,12 @@ impl Deterministic {
|
||||||
let mut state = self.state.lock();
|
let mut state = self.state.lock();
|
||||||
let wakeup_at = state.now + duration;
|
let wakeup_at = state.now + duration;
|
||||||
let id = util::post_inc(&mut state.next_timer_id);
|
let id = util::post_inc(&mut state.next_timer_id);
|
||||||
state.pending_timers.push((id, wakeup_at, tx));
|
match state
|
||||||
|
.pending_timers
|
||||||
|
.binary_search_by_key(&wakeup_at, |e| e.1)
|
||||||
|
{
|
||||||
|
Ok(ix) | Err(ix) => state.pending_timers.insert(ix, (id, wakeup_at, tx)),
|
||||||
|
}
|
||||||
let state = self.state.clone();
|
let state = self.state.clone();
|
||||||
Timer::Deterministic(DeterministicTimer { rx, id, state })
|
Timer::Deterministic(DeterministicTimer { rx, id, state })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue