Change summary
crates/scheduler/src/clock.rs | 5 +++++
crates/scheduler/src/test_scheduler.rs | 6 ++++++
2 files changed, 11 insertions(+)
Detailed changes
@@ -24,6 +24,11 @@ impl TestClock {
}))
}
+ pub fn set_utc_now(&self, now: DateTime<Utc>) {
+ let mut state = self.0.lock();
+ state.utc_now = now;
+ }
+
pub fn advance(&self, duration: Duration) {
let mut state = self.0.lock();
state.now += duration;
@@ -135,6 +135,12 @@ impl TestScheduler {
}
}
+ pub fn run_with_clock_advancement(&self) {
+ while self.step() || self.advance_clock_to_next_timer() {
+ // Continue until no work remains
+ }
+ }
+
fn step(&self) -> bool {
let elapsed_timers = {
let mut state = self.state.lock();