diff --git a/gpui/src/app.rs b/gpui/src/app.rs index 9043801c4c..52363a9d12 100644 --- a/gpui/src/app.rs +++ b/gpui/src/app.rs @@ -311,7 +311,6 @@ pub struct MutableAppContext { invalidation_callbacks: HashMap>, foreground: Rc, - background: Arc, future_handlers: Rc>>, stream_handlers: Rc>>, task_done: Arc, @@ -336,6 +335,7 @@ impl MutableAppContext { models: HashMap::new(), windows: HashMap::new(), ref_counts: Arc::new(Mutex::new(RefCounts::default())), + background: Arc::new(executor::Background::new()), }, actions: HashMap::new(), global_actions: HashMap::new(), @@ -348,7 +348,6 @@ impl MutableAppContext { window_invalidations: HashMap::new(), invalidation_callbacks: HashMap::new(), foreground, - background: Arc::new(executor::Background::new()), future_handlers: Default::default(), stream_handlers: Default::default(), task_done: Default::default(), @@ -366,8 +365,12 @@ impl MutableAppContext { &self.ctx } - pub fn foreground_executor(&self) -> Rc { - self.foreground.clone() + pub fn foreground_executor(&self) -> &Rc { + &self.foreground + } + + pub fn background_executor(&self) -> &Arc { + &self.ctx.background } pub fn on_window_invalidated( @@ -1294,6 +1297,7 @@ impl UpdateView for MutableAppContext { pub struct AppContext { models: HashMap>, windows: HashMap, + background: Arc, ref_counts: Arc>, } @@ -1329,6 +1333,10 @@ impl AppContext { }) .ok_or(anyhow!("window not found")) } + + pub fn background_executor(&self) -> &Arc { + &self.background + } } impl ModelAsRef for AppContext { @@ -1480,7 +1488,7 @@ impl<'a, T: Entity> ModelContext<'a, T> { } pub fn background_executor(&self) -> &Arc { - &self.app.background + &self.app.ctx.background } pub fn halt_stream(&mut self) { @@ -1673,7 +1681,7 @@ impl<'a, T: View> ViewContext<'a, T> { } pub fn background_executor(&self) -> &Arc { - &self.app.background + &self.app.ctx.background } pub fn focus(&mut self, handle: S)