Avoid panic when spawn is called after run exits in deterministic executor

This commit is contained in:
Max Brunsfeld 2021-07-08 17:31:52 -07:00
parent 9bfa5b62f2
commit 2965fce70d

View file

@ -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