From a69dbafe3c92ae1ce6595f9f721ea0dfa75d0093 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 11 Oct 2023 12:47:19 +0200 Subject: [PATCH] Checkpoint --- 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(-) diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rs index 20dc3d3f348685fbdcc6b13baa064e58558ca0a1..90c024f83d24b6cf7cb65a6a6b7612ada1e4a2f9 100644 --- a/crates/gpui3/src/app.rs +++ b/crates/gpui3/src/app.rs @@ -88,8 +88,8 @@ impl App { } } -type Handler = Arc bool + Send + Sync + 'static>; -type EventHandler = Arc bool + Send + Sync + 'static>; +type Handler = Box bool + Send + Sync + 'static>; +type EventHandler = Box bool + Send + Sync + 'static>; type FrameCallback = Box; pub struct AppContext { diff --git a/crates/gpui3/src/app/model_context.rs b/crates/gpui3/src/app/model_context.rs index 0b30442feffcaeb017fd757d63b92108d9b08db5..56e10e489bcd8636ed67a1312a12bd7a023e1f4a 100644 --- a/crates/gpui3/src/app/model_context.rs +++ b/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)); diff --git a/crates/gpui3/src/subscription.rs b/crates/gpui3/src/subscription.rs index 4eaf9d9787c1a3fbb50eaea0e38fb71985be05d5..509b29e46861098fcb591c962fc78b563e7a442d 100644 --- a/crates/gpui3/src/subscription.rs +++ b/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( Arc>>, ); +impl Clone for SubscriberSet { + fn clone(&self) -> Self { + SubscriberSet(self.0.clone()) + } +} + struct SubscriberSetState { subscribers: BTreeMap>, dropped_subscribers: BTreeSet<(EmitterKey, usize)>, diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rs index 1c0ded433e529acfbb42ae08c69e69cdc9c0bd5c..02dbe7c629b5a36625bd6cf7d314d62bab8aef2f 100644 --- a/crates/gpui3/src/window.rs +++ b/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");