From f3b6719c76a9d540470fca417491ec5c2f1d21d4 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 16 Nov 2023 19:58:18 -0800 Subject: [PATCH] Rename both PlatformDispatcher::poll and Executor::run_step to 'tick' Co-authored-by: Nathan Sobo --- crates/gpui2/src/app/test_context.rs | 2 +- crates/gpui2/src/executor.rs | 6 +++--- crates/gpui2/src/platform.rs | 2 +- crates/gpui2/src/platform/mac/dispatcher.rs | 2 +- crates/gpui2/src/platform/test/dispatcher.rs | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/gpui2/src/app/test_context.rs b/crates/gpui2/src/app/test_context.rs index 37f81da15b..f78162589e 100644 --- a/crates/gpui2/src/app/test_context.rs +++ b/crates/gpui2/src/app/test_context.rs @@ -359,7 +359,7 @@ impl Model { Ok(Some(event)) => return event, Ok(None) => panic!("model was dropped"), Err(_) => { - if !cx.executor().run_step() { + if !cx.executor().tick() { break; } } diff --git a/crates/gpui2/src/executor.rs b/crates/gpui2/src/executor.rs index b29fbbb5a1..21b67b445d 100644 --- a/crates/gpui2/src/executor.rs +++ b/crates/gpui2/src/executor.rs @@ -158,7 +158,7 @@ impl BackgroundExecutor { match future.as_mut().poll(&mut cx) { Poll::Ready(result) => return result, Poll::Pending => { - if !self.dispatcher.poll(background_only) { + if !self.dispatcher.tick(background_only) { if awoken.swap(false, SeqCst) { continue; } @@ -255,8 +255,8 @@ impl BackgroundExecutor { } #[cfg(any(test, feature = "test-support"))] - pub fn run_step(&self) -> bool { - self.dispatcher.as_test().unwrap().poll(false) + pub fn tick(&self) -> bool { + self.dispatcher.as_test().unwrap().tick(false) } #[cfg(any(test, feature = "test-support"))] diff --git a/crates/gpui2/src/platform.rs b/crates/gpui2/src/platform.rs index 882dc332ef..3027c05fbd 100644 --- a/crates/gpui2/src/platform.rs +++ b/crates/gpui2/src/platform.rs @@ -165,7 +165,7 @@ pub trait PlatformDispatcher: Send + Sync { fn dispatch(&self, runnable: Runnable, label: Option); fn dispatch_on_main_thread(&self, runnable: Runnable); fn dispatch_after(&self, duration: Duration, runnable: Runnable); - fn poll(&self, background_only: bool) -> bool; + fn tick(&self, background_only: bool) -> bool; fn park(&self); fn unparker(&self) -> Unparker; diff --git a/crates/gpui2/src/platform/mac/dispatcher.rs b/crates/gpui2/src/platform/mac/dispatcher.rs index 1752f78601..2fb0eef3e5 100644 --- a/crates/gpui2/src/platform/mac/dispatcher.rs +++ b/crates/gpui2/src/platform/mac/dispatcher.rs @@ -71,7 +71,7 @@ impl PlatformDispatcher for MacDispatcher { } } - fn poll(&self, _background_only: bool) -> bool { + fn tick(&self, _background_only: bool) -> bool { false } diff --git a/crates/gpui2/src/platform/test/dispatcher.rs b/crates/gpui2/src/platform/test/dispatcher.rs index 3abe4796b3..e77c1c0529 100644 --- a/crates/gpui2/src/platform/test/dispatcher.rs +++ b/crates/gpui2/src/platform/test/dispatcher.rs @@ -113,7 +113,7 @@ impl TestDispatcher { } pub fn run_until_parked(&self) { - while self.poll(false) {} + while self.tick(false) {} } pub fn parking_allowed(&self) -> bool { @@ -194,7 +194,7 @@ impl PlatformDispatcher for TestDispatcher { state.delayed.insert(ix, (next_time, runnable)); } - fn poll(&self, background_only: bool) -> bool { + fn tick(&self, background_only: bool) -> bool { let mut state = self.state.lock(); while let Some((deadline, _)) = state.delayed.first() {