mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
Avoid spawn_local instantiations due to different scheduling closure
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
48f9bc972a
commit
8370b3075e
1 changed files with 16 additions and 6 deletions
|
@ -23,7 +23,10 @@ use std::{
|
||||||
};
|
};
|
||||||
use waker_fn::waker_fn;
|
use waker_fn::waker_fn;
|
||||||
|
|
||||||
use crate::{platform, util};
|
use crate::{
|
||||||
|
platform::{self, Dispatcher},
|
||||||
|
util,
|
||||||
|
};
|
||||||
|
|
||||||
pub enum Foreground {
|
pub enum Foreground {
|
||||||
Platform {
|
Platform {
|
||||||
|
@ -398,12 +401,19 @@ impl Foreground {
|
||||||
let any_task = match self {
|
let any_task = match self {
|
||||||
Self::Deterministic(executor) => executor.spawn_from_foreground(future),
|
Self::Deterministic(executor) => executor.spawn_from_foreground(future),
|
||||||
Self::Platform { dispatcher, .. } => {
|
Self::Platform { dispatcher, .. } => {
|
||||||
|
fn spawn_inner(
|
||||||
|
future: AnyLocalFuture,
|
||||||
|
dispatcher: &Arc<dyn Dispatcher>,
|
||||||
|
) -> AnyLocalTask {
|
||||||
let dispatcher = dispatcher.clone();
|
let dispatcher = dispatcher.clone();
|
||||||
let schedule = move |runnable: Runnable| dispatcher.run_on_main_thread(runnable);
|
let schedule =
|
||||||
|
move |runnable: Runnable| dispatcher.run_on_main_thread(runnable);
|
||||||
let (runnable, task) = async_task::spawn_local(future, schedule);
|
let (runnable, task) = async_task::spawn_local(future, schedule);
|
||||||
runnable.schedule();
|
runnable.schedule();
|
||||||
task
|
task
|
||||||
}
|
}
|
||||||
|
spawn_inner(future, dispatcher)
|
||||||
|
}
|
||||||
Self::Test(executor) => executor.spawn(future),
|
Self::Test(executor) => executor.spawn(future),
|
||||||
};
|
};
|
||||||
Task::local(any_task)
|
Task::local(any_task)
|
||||||
|
|
Loading…
Reference in a new issue