Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

scheduler: Add missing constructs for Cloud (#37948)

Marshall Bowersdb367cc6bfeb
diff --git a/crates/scheduler/src/clock.rs b/crates/scheduler/src/clock.rs
index 447d76b584a..017643c4eb7 100644
--- a/crates/scheduler/src/clock.rs
+++ b/crates/scheduler/src/clock.rs
@@ -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;
diff --git a/crates/scheduler/src/test_scheduler.rs b/crates/scheduler/src/test_scheduler.rs
index 243f6f756df..d9523640f4c 100644
--- a/crates/scheduler/src/test_scheduler.rs
+++ b/crates/scheduler/src/test_scheduler.rs
@@ -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();