From 2965fce70d14e917f42aa1e2f239beb92eae41b5 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 8 Jul 2021 17:31:52 -0700 Subject: [PATCH] Avoid panic when spawn is called after run exits in deterministic executor --- gpui/src/executor.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gpui/src/executor.rs b/gpui/src/executor.rs index 75a36f8088..715d6f2874 100644 --- a/gpui/src/executor.rs +++ b/gpui/src/executor.rs @@ -51,7 +51,9 @@ impl Deterministic { let (runnable, task) = async_task::spawn_local(future, move |runnable| { let mut runnables = runnables.lock(); runnables.0.push(runnable); - runnables.1.as_ref().unwrap().send(()).ok(); + if let Some(wake_tx) = runnables.1.as_ref() { + wake_tx.send(()).ok(); + } }); runnable.schedule(); task @@ -66,7 +68,9 @@ impl Deterministic { let (runnable, task) = async_task::spawn(future, move |runnable| { let mut runnables = runnables.lock(); runnables.0.push(runnable); - runnables.1.as_ref().unwrap().send(()).ok(); + if let Some(wake_tx) = runnables.1.as_ref() { + wake_tx.send(()).ok(); + } }); runnable.schedule(); task