Explorar o código

Don't notify task if ready

kidkool850@gmail.com hai 1 ano
pai
achega
ed2ce6e039
Modificáronse 1 ficheiros con 6 adicións e 5 borrados
  1. 6 5
      packages/core/src/scheduler/task.rs

+ 6 - 5
packages/core/src/scheduler/task.rs

@@ -49,13 +49,14 @@ impl Scheduler {
         };
 
         let mut cx = std::task::Context::from_waker(&task.waker);
-        let _ = task.task.borrow_mut().as_mut().poll(&mut cx);
 
-        entry.insert(task);
+        if !task.task.borrow_mut().as_mut().poll(&mut cx).is_ready() {
+            self.sender
+                .unbounded_send(SchedulerMsg::TaskNotified(task_id))
+                .expect("Scheduler should exist");
+        }
 
-        self.sender
-            .unbounded_send(SchedulerMsg::TaskNotified(task_id))
-            .expect("Scheduler should exist");
+        entry.insert(task);
 
         task_id
     }