diff options
Diffstat (limited to 'embassy-executor/src/raw/run_queue_critical_section.rs')
| -rw-r--r-- | embassy-executor/src/raw/run_queue_critical_section.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/embassy-executor/src/raw/run_queue_critical_section.rs b/embassy-executor/src/raw/run_queue_critical_section.rs index 4f1b2855a..86c4085ed 100644 --- a/embassy-executor/src/raw/run_queue_critical_section.rs +++ b/embassy-executor/src/raw/run_queue_critical_section.rs | |||
| @@ -63,19 +63,12 @@ impl RunQueue { | |||
| 63 | // If the task re-enqueues itself, the `next` pointer will get overwritten. | 63 | // If the task re-enqueues itself, the `next` pointer will get overwritten. |
| 64 | // Therefore, first read the next pointer, and only then process the task. | 64 | // Therefore, first read the next pointer, and only then process the task. |
| 65 | 65 | ||
| 66 | let run_task = critical_section::with(|cs| { | 66 | critical_section::with(|cs| { |
| 67 | next = task.header().run_queue_item.next.borrow(cs).get(); | 67 | next = task.header().run_queue_item.next.borrow(cs).get(); |
| 68 | task.header().state.run_dequeue(cs) | 68 | task.header().state.run_dequeue(cs); |
| 69 | }); | 69 | }); |
| 70 | 70 | ||
| 71 | if run_task { | 71 | on_task(task); |
| 72 | // If task is not running, ignore it. This can happen in the following scenario: | ||
| 73 | // - Task gets dequeued, poll starts | ||
| 74 | // - While task is being polled, it gets woken. It gets placed in the queue. | ||
| 75 | // - Task poll finishes, returning done=true | ||
| 76 | // - RUNNING bit is cleared, but the task is already in the queue. | ||
| 77 | on_task(task); | ||
| 78 | } | ||
| 79 | } | 72 | } |
| 80 | } | 73 | } |
| 81 | } | 74 | } |
