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: Spawn at least two background threads (#44110)

Agus Zubiaga9db0d662518c
diff --git a/crates/gpui/src/platform/linux/dispatcher.rs b/crates/gpui/src/platform/linux/dispatcher.rs
index c300109ffe3..d0c32140f36 100644
--- a/crates/gpui/src/platform/linux/dispatcher.rs
+++ b/crates/gpui/src/platform/linux/dispatcher.rs
@@ -26,12 +26,13 @@ pub(crate) struct LinuxDispatcher {
main_thread_id: thread::ThreadId,
}
+const MIN_THREADS: usize = 2;
+
impl LinuxDispatcher {
pub fn new(main_sender: Sender<RunnableVariant>) -> Self {
let (background_sender, background_receiver) = flume::unbounded::<RunnableVariant>();
- let thread_count = std::thread::available_parallelism()
- .map(|i| i.get())
- .unwrap_or(1);
+ let thread_count =
+ std::thread::available_parallelism().map_or(MIN_THREADS, |i| i.get().max(MIN_THREADS));
let mut background_threads = (0..thread_count)
.map(|i| {