only poll suspended futures

This commit is contained in:
Evan Almloff committed 2024-03-05 18:24:01 -06:00
1 parent 608fec59e5
commit c9603ea984
7 files changed
+140 -46

No files matched your search

+8 -2
View File
@@ -1,3 +1,5 @@
use rustc_hash::FxHashSet;
use crate::{
innerlude::{LocalTask, SchedulerMsg},
render_signal::RenderSignal,
@@ -24,11 +26,14 @@ pub struct Runtime {
// We use this to track the current task
pub(crate) current_task: Cell<Option<Task>>,
pub(crate) rendering: Cell<bool>,
/// Tasks created with cx.spawn
pub(crate) tasks: RefCell<slab::Slab<Rc<LocalTask>>>,
// Currently suspended tasks
pub(crate) suspended_tasks: RefCell<FxHashSet<Task>>,
pub(crate) rendering: Cell<bool>,
pub(crate) sender: futures_channel::mpsc::UnboundedSender<SchedulerMsg>,
// Synchronous tasks need to be run after the next render. The virtual dom stores a list of those tasks to send a signal to them when the next render is done.
@@ -45,6 +50,7 @@ impl Runtime {
scope_stack: Default::default(),
current_task: Default::default(),
tasks: Default::default(),
suspended_tasks: Default::default(),
})
}