aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/run_queue_critical_section.rs
diff options
context:
space:
mode:
authorjrmoulton <[email protected]>2025-06-10 15:47:54 -0600
committerjrmoulton <[email protected]>2025-06-10 15:48:36 -0600
commitcfad9798ff99d4de0571a512d156b5fe1ef1d427 (patch)
treefc3bf670f82d139de19466cddad1e909db7f3d2e /embassy-executor/src/raw/run_queue_critical_section.rs
parentfc342915e6155dec7bafa3e135da7f37a9a07f5c (diff)
parent6186d111a5c150946ee5b7e9e68d987a38c1a463 (diff)
merge new embassy changes
Diffstat (limited to 'embassy-executor/src/raw/run_queue_critical_section.rs')
-rw-r--r--embassy-executor/src/raw/run_queue_critical_section.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/embassy-executor/src/raw/run_queue_critical_section.rs b/embassy-executor/src/raw/run_queue_critical_section.rs
index ba59c8f29..86c4085ed 100644
--- a/embassy-executor/src/raw/run_queue_critical_section.rs
+++ b/embassy-executor/src/raw/run_queue_critical_section.rs
@@ -44,13 +44,11 @@ impl RunQueue {
44 /// 44 ///
45 /// `item` must NOT be already enqueued in any queue. 45 /// `item` must NOT be already enqueued in any queue.
46 #[inline(always)] 46 #[inline(always)]
47 pub(crate) unsafe fn enqueue(&self, task: TaskRef) -> bool { 47 pub(crate) unsafe fn enqueue(&self, task: TaskRef, cs: CriticalSection<'_>) -> bool {
48 critical_section::with(|cs| { 48 let prev = self.head.borrow(cs).replace(Some(task));
49 let prev = self.head.borrow(cs).replace(Some(task)); 49 task.header().run_queue_item.next.borrow(cs).set(prev);
50 task.header().run_queue_item.next.borrow(cs).set(prev);
51 50
52 prev.is_none() 51 prev.is_none()
53 })
54 } 52 }
55 53
56 /// Empty the queue, then call `on_task` for each task that was in the queue. 54 /// Empty the queue, then call `on_task` for each task that was in the queue.
@@ -65,9 +63,10 @@ impl RunQueue {
65 // 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.
66 // 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.
67 65
68 // safety: we know if the task is enqueued, no one else will touch the `next` pointer. 66 critical_section::with(|cs| {
69 let cs = unsafe { CriticalSection::new() }; 67 next = task.header().run_queue_item.next.borrow(cs).get();
70 next = task.header().run_queue_item.next.borrow(cs).get(); 68 task.header().state.run_dequeue(cs);
69 });
71 70
72 on_task(task); 71 on_task(task);
73 } 72 }