diff options
| author | Dániel Buga <[email protected]> | 2024-12-17 18:05:48 +0100 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2024-12-17 18:07:06 +0100 |
| commit | 8fd08b1e97533c7526bb4937770060d18bb37410 (patch) | |
| tree | 3e30a41e0d630f6b472bd85a4407f600ca07410a /embassy-executor/src/raw/run_queue_critical_section.rs | |
| parent | edb8f21a741358f7c80b744f008f1e5acc77b429 (diff) | |
Swap poll_fn to allow polling exited tasks
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 | } |
