gpui: Do not use a single shared parker within a Dispatcher (#40417)

This caused issues with #40172, as it made Zed execute and block on tad
few more background tasks. Parker is ~cheap to create, hence we should
be ok to just create it at the time it is needed.

Release Notes:

- N/A

---------

Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
Piotr Osiewicz
2025-10-16 21:52:09 +00:00
committed by GitHub
co-authored by Cole Miller
parent 59991e9c4d
commit 3780fe3b8e
7 changed files with 41 additions and 97 deletions
@@ -5,8 +5,6 @@ use calloop::{
channel::{self, Sender},
timer::TimeoutAction,
};
use parking::{Parker, Unparker};
use parking_lot::Mutex;
use std::{
thread,
time::{Duration, Instant},
@@ -19,7 +17,6 @@ struct TimerAfter {
}
pub(crate) struct LinuxDispatcher {
parker: Mutex<Parker>,
main_sender: Sender<Runnable>,
timer_sender: Sender<TimerAfter>,
background_sender: flume::Sender<Runnable>,
@@ -92,7 +89,6 @@ impl LinuxDispatcher {
background_threads.push(timer_thread);
Self {
parker: Mutex::new(Parker::new()),
main_sender,
timer_sender,
background_sender,
@@ -130,17 +126,4 @@ impl PlatformDispatcher for LinuxDispatcher {
.send(TimerAfter { duration, runnable })
.ok();
}
fn park(&self, timeout: Option<Duration>) -> bool {
if let Some(timeout) = timeout {
self.parker.lock().park_timeout(timeout)
} else {
self.parker.lock().park();
true
}
}
fn unparker(&self) -> Unparker {
self.parker.lock().unparker()
}
}