Checkpoint

Antonio Scandurra created

Change summary

crates/gpui3/src/app.rs               | 4 ++--
crates/gpui3/src/app/model_context.rs | 6 +++---
crates/gpui3/src/subscription.rs      | 7 ++++++-
crates/gpui3/src/window.rs            | 4 ++--
4 files changed, 13 insertions(+), 8 deletions(-)

Detailed changes

crates/gpui3/src/app.rs 🔗

@@ -88,8 +88,8 @@ impl App {
     }
 }
 
-type Handler = Arc<dyn Fn(&mut AppContext) -> bool + Send + Sync + 'static>;
-type EventHandler = Arc<dyn Fn(&dyn Any, &mut AppContext) -> bool + Send + Sync + 'static>;
+type Handler = Box<dyn Fn(&mut AppContext) -> bool + Send + Sync + 'static>;
+type EventHandler = Box<dyn Fn(&dyn Any, &mut AppContext) -> bool + Send + Sync + 'static>;
 type FrameCallback = Box<dyn FnOnce(&mut WindowContext) + Send>;
 
 pub struct AppContext {

crates/gpui3/src/app/model_context.rs 🔗

@@ -2,7 +2,7 @@ use crate::{
     AppContext, Context, Effect, EntityId, EventEmitter, Handle, Reference, Subscription,
     WeakHandle,
 };
-use std::{marker::PhantomData, sync::Arc};
+use std::marker::PhantomData;
 
 pub struct ModelContext<'a, T> {
     app: Reference<'a, AppContext>,
@@ -50,7 +50,7 @@ impl<'a, T: Send + Sync + 'static> ModelContext<'a, T> {
         let handle = handle.downgrade();
         self.app.observers.insert(
             handle.id,
-            Arc::new(move |cx| {
+            Box::new(move |cx| {
                 if let Some((this, handle)) = this.upgrade(cx).zip(handle.upgrade(cx)) {
                     this.update(cx, |this, cx| on_notify(this, handle, cx));
                     true
@@ -73,7 +73,7 @@ impl<'a, T: Send + Sync + 'static> ModelContext<'a, T> {
         let handle = handle.downgrade();
         self.app.event_handlers.insert(
             handle.id,
-            Arc::new(move |event, cx| {
+            Box::new(move |event, cx| {
                 let event = event.downcast_ref().expect("invalid event type");
                 if let Some((this, handle)) = this.upgrade(cx).zip(handle.upgrade(cx)) {
                     this.update(cx, |this, cx| on_event(this, handle, event, cx));

crates/gpui3/src/subscription.rs 🔗

@@ -3,11 +3,16 @@ use parking_lot::Mutex;
 use std::{fmt::Debug, mem, sync::Arc};
 use util::post_inc;
 
-#[derive(Clone)]
 pub(crate) struct SubscriberSet<EmitterKey, Callback>(
     Arc<Mutex<SubscriberSetState<EmitterKey, Callback>>>,
 );
 
+impl<EmitterKey, Callback> Clone for SubscriberSet<EmitterKey, Callback> {
+    fn clone(&self) -> Self {
+        SubscriberSet(self.0.clone())
+    }
+}
+
 struct SubscriberSetState<EmitterKey, Callback> {
     subscribers: BTreeMap<EmitterKey, BTreeMap<usize, Callback>>,
     dropped_subscribers: BTreeSet<(EmitterKey, usize)>,

crates/gpui3/src/window.rs 🔗

@@ -909,7 +909,7 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {
         let window_handle = self.window.handle;
         self.app.observers.insert(
             handle.id,
-            Arc::new(move |cx| {
+            Box::new(move |cx| {
                 cx.update_window(window_handle.id, |cx| {
                     if let Some(handle) = handle.upgrade(cx) {
                         this.update(cx, |this, cx| on_notify(this, handle, cx))
@@ -936,7 +936,7 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {
         let window_handle = self.window.handle;
         self.app.event_handlers.insert(
             handle.id,
-            Arc::new(move |event, cx| {
+            Box::new(move |event, cx| {
                 cx.update_window(window_handle.id, |cx| {
                     if let Some(handle) = handle.upgrade(cx) {
                         let event = event.downcast_ref().expect("invalid event type");