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.

linux: only tick the main thread tasks and one at a time in the event loop

Dzmitry Malyshau1c410c1b9960
diff --git a/crates/gpui/screenshot.png b/crates/gpui/screenshot.png
new file mode 100644
index 00000000000..50597680f03
Binary files /dev/null and b/crates/gpui/screenshot.png differ
diff --git a/crates/gpui/src/platform/linux/dispatcher.rs b/crates/gpui/src/platform/linux/dispatcher.rs
index 14072f040a5..d669e56ab6e 100644
--- a/crates/gpui/src/platform/linux/dispatcher.rs
+++ b/crates/gpui/src/platform/linux/dispatcher.rs
@@ -46,6 +46,13 @@ impl LinuxDispatcher {
main_thread_id: thread::current().id(),
}
}
+
+ pub fn tick_main(&self) {
+ assert!(self.is_main_thread());
+ if let Ok(runnable) = self.main_receiver.try_recv() {
+ runnable.run();
+ }
+ }
}
impl PlatformDispatcher for LinuxDispatcher {
diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs
index b7d51971a19..e1d21ef69d4 100644
--- a/crates/gpui/src/platform/linux/platform.rs
+++ b/crates/gpui/src/platform/linux/platform.rs
@@ -3,9 +3,8 @@
use crate::{
Action, AnyWindowHandle, BackgroundExecutor, Bounds, ClipboardItem, CursorStyle, DisplayId,
ForegroundExecutor, Keymap, LinuxDispatcher, LinuxDisplay, LinuxTextSystem, LinuxWindow,
- LinuxWindowState, Menu, PathPromptOptions, Platform, PlatformDispatcher as _, PlatformDisplay,
- PlatformInput, PlatformTextSystem, PlatformWindow, Point, Result, SemanticVersion, Size, Task,
- WindowOptions,
+ LinuxWindowState, Menu, PathPromptOptions, Platform, PlatformDisplay, PlatformInput,
+ PlatformTextSystem, PlatformWindow, Point, Result, SemanticVersion, Size, Task, WindowOptions,
};
use collections::{HashMap, HashSet};
@@ -121,7 +120,7 @@ impl Platform for LinuxPlatform {
}
_ => {}
}
- self.0.lock().dispatcher.tick(false);
+ self.0.lock().dispatcher.tick_main();
}
}