@@ -68,7 +68,7 @@ pub struct WasmHost {
#[derive(Clone, Debug)]
pub struct WasmExtension {
- tx: UnboundedSender<ExtensionCall>,
+ tx: Arc<UnboundedSender<ExtensionCall>>,
pub manifest: Arc<ExtensionManifest>,
pub work_dir: Arc<Path>,
#[allow(unused)]
@@ -76,6 +76,15 @@ pub struct WasmExtension {
_task: Arc<Task<Result<(), gpui_tokio::JoinError>>>,
}
+impl Drop for WasmExtension {
+ fn drop(&mut self) {
+ // Only close the channel when this is the last clone holding the sender
+ if Arc::strong_count(&self.tx) == 1 {
+ self.tx.close_channel();
+ }
+ }
+}
+
#[async_trait]
impl extension::Extension for WasmExtension {
fn manifest(&self) -> Arc<ExtensionManifest> {
@@ -670,7 +679,7 @@ impl WasmHost {
Ok(WasmExtension {
manifest,
work_dir,
- tx,
+ tx: Arc::new(tx),
zed_api_version,
_task: task,
})