diff --git a/packages/core/src/scopes.rs b/packages/core/src/scopes.rs index 00c3024bf..1e58dcfd2 100644 --- a/packages/core/src/scopes.rs +++ b/packages/core/src/scopes.rs @@ -7,7 +7,7 @@ use std::{ any::{Any, TypeId}, borrow::Borrow, cell::{Cell, RefCell}, - collections::HashMap, + collections::{HashMap, HashSet}, future::Future, pin::Pin, rc::Rc, @@ -179,6 +179,9 @@ impl ScopeArena { log::trace!("removing scope {:?}", id); self.ensure_drop_safety(id); + // + let tasks = self.tasks.tasks.borrow_mut(); + // Safety: // - ensure_drop_safety ensures that no references to this scope are in use // - this raw pointer is removed from the map @@ -933,14 +936,17 @@ impl BumpFrame { pub(crate) struct TaskQueue { pub(crate) tasks: RefCell>, + pub(crate) task_map: RefCell>>, gen: Cell, sender: UnboundedSender, } + pub(crate) type InnerTask = Pin>>; impl TaskQueue { fn new(sender: UnboundedSender) -> Rc { Rc::new(Self { tasks: RefCell::new(FxHashMap::default()), + task_map: RefCell::new(FxHashMap::default()), gen: Cell::new(0), sender, }) @@ -957,10 +963,6 @@ impl TaskQueue { fn remove_fut(&self, id: TaskId) { if let Ok(mut tasks) = self.tasks.try_borrow_mut() { let _ = tasks.remove(&id); - } else { - // todo: it should be okay to remote a fut while the queue is being polled - // However, it's not currently possible to do that. - log::trace!("Unable to remove task from task queue. This is probably a bug."); } } pub(crate) fn has_tasks(&self) -> bool {