sum_tree: Replace rayon with futures (#41586)
Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored by: Kate <kate@zed.dev>
This commit is contained in:
@@ -260,6 +260,19 @@ impl AsyncApp {
|
||||
}
|
||||
}
|
||||
|
||||
impl sum_tree::BackgroundSpawn for BackgroundExecutor {
|
||||
type Task<R>
|
||||
= Task<R>
|
||||
where
|
||||
R: Send + Sync;
|
||||
fn background_spawn<R>(&self, future: impl Future<Output = R> + Send + 'static) -> Self::Task<R>
|
||||
where
|
||||
R: Send + Sync + 'static,
|
||||
{
|
||||
self.spawn(future)
|
||||
}
|
||||
}
|
||||
|
||||
/// A cloneable, owned handle to the application context,
|
||||
/// composed with the window associated with the current task.
|
||||
#[derive(Clone, Deref, DerefMut)]
|
||||
|
||||
@@ -393,6 +393,11 @@ impl TestAppContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the background executor for this context.
|
||||
pub fn background_executor(&self) -> &BackgroundExecutor {
|
||||
&self.background_executor
|
||||
}
|
||||
|
||||
/// Wait until there are no more pending tasks.
|
||||
pub fn run_until_parked(&mut self) {
|
||||
self.background_executor.run_until_parked()
|
||||
|
||||
@@ -342,7 +342,7 @@ impl BackgroundExecutor {
|
||||
/// for all of them to complete before returning.
|
||||
pub async fn scoped<'scope, F>(&self, scheduler: F)
|
||||
where
|
||||
F: FnOnce(&mut Scope<'scope>),
|
||||
F: for<'a> FnOnce(&'a mut Scope<'scope>),
|
||||
{
|
||||
let mut scope = Scope::new(self.clone());
|
||||
(scheduler)(&mut scope);
|
||||
|
||||
Reference in New Issue
Block a user