Never remove queued tasks without polling during suspense
This commit is contained in:
1 parent
3e9a360b55
commit
88e2dc127a
1 file changed
+7
-2
@@ -468,6 +468,7 @@ impl VirtualDom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for the next event to trigger and add it to the queue
|
/// Wait for the next event to trigger and add it to the queue
|
||||||
|
#[instrument(skip(self), level = "trace", name = "VirtualDom::wait_for_event")]
|
||||||
async fn wait_for_event(&mut self) {
|
async fn wait_for_event(&mut self) {
|
||||||
match self.rx.next().await.expect("channel should never close") {
|
match self.rx.next().await.expect("channel should never close") {
|
||||||
SchedulerMsg::Immediate(id) => self.mark_dirty(id),
|
SchedulerMsg::Immediate(id) => self.mark_dirty(id),
|
||||||
@@ -666,13 +667,17 @@ impl VirtualDom {
|
|||||||
// We choose not to poll the deadline since we complete pretty quickly anyways
|
// We choose not to poll the deadline since we complete pretty quickly anyways
|
||||||
while let Some(task) = self.pop_task() {
|
while let Some(task) = self.pop_task() {
|
||||||
// Then poll any tasks that might be pending
|
// Then poll any tasks that might be pending
|
||||||
let tasks = task.tasks_queued.into_inner();
|
let mut tasks = task.tasks_queued.into_inner();
|
||||||
for task in tasks {
|
while let Some(task) = tasks.pop() {
|
||||||
if self.runtime.task_runs_during_suspense(task) {
|
if self.runtime.task_runs_during_suspense(task) {
|
||||||
let _ = self.runtime.handle_task_wakeup(task);
|
let _ = self.runtime.handle_task_wakeup(task);
|
||||||
// Running that task, may mark a scope higher up as dirty. If it does, return from the function early
|
// Running that task, may mark a scope higher up as dirty. If it does, return from the function early
|
||||||
self.queue_events();
|
self.queue_events();
|
||||||
if self.has_dirty_scopes() {
|
if self.has_dirty_scopes() {
|
||||||
|
// requeue any remaining tasks
|
||||||
|
for task in tasks {
|
||||||
|
self.mark_task_dirty(task);
|
||||||
|
}
|
||||||
break 'wait_for_work;
|
break 'wait_for_work;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user