aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/run_queue.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/raw/run_queue.rs')
-rw-r--r--embassy-executor/src/raw/run_queue.rs28
1 files changed, 17 insertions, 11 deletions
diff --git a/embassy-executor/src/raw/run_queue.rs b/embassy-executor/src/raw/run_queue.rs
index b4b22819f..9acb9dd28 100644
--- a/embassy-executor/src/raw/run_queue.rs
+++ b/embassy-executor/src/raw/run_queue.rs
@@ -70,8 +70,12 @@ impl RunQueue {
70 /// 70 ///
71 /// `item` must NOT be already enqueued in any queue. 71 /// `item` must NOT be already enqueued in any queue.
72 #[inline(always)] 72 #[inline(always)]
73 pub(crate) unsafe fn enqueue(&self, task: TaskRef, _: super::state::Token) -> bool { 73 pub(crate) unsafe fn enqueue(&self, task: TaskRef, _tok: super::state::Token) -> bool {
74 self.stack.push_was_empty(task) 74 self.stack.push_was_empty(
75 task,
76 #[cfg(not(target_has_atomic = "ptr"))]
77 _tok,
78 )
75 } 79 }
76 80
77 /// # Standard atomic runqueue 81 /// # Standard atomic runqueue
@@ -153,26 +157,28 @@ fn run_dequeue(taskref: &TaskRef) {
153/// A wrapper type that acts like TransferStack by wrapping a normal Stack in a CS mutex 157/// A wrapper type that acts like TransferStack by wrapping a normal Stack in a CS mutex
154#[cfg(not(target_has_atomic = "ptr"))] 158#[cfg(not(target_has_atomic = "ptr"))]
155struct MutexTransferStack<T: Linked<cordyceps::stack::Links<T>>> { 159struct MutexTransferStack<T: Linked<cordyceps::stack::Links<T>>> {
156 inner: mutex::BlockingMutex<mutex::raw_impls::cs::CriticalSectionRawMutex, cordyceps::Stack<T>>, 160 inner: critical_section::Mutex<core::cell::RefCell<cordyceps::Stack<T>>>,
157} 161}
158 162
159#[cfg(not(target_has_atomic = "ptr"))] 163#[cfg(not(target_has_atomic = "ptr"))]
160impl<T: Linked<cordyceps::stack::Links<T>>> MutexTransferStack<T> { 164impl<T: Linked<cordyceps::stack::Links<T>>> MutexTransferStack<T> {
161 const fn new() -> Self { 165 const fn new() -> Self {
162 Self { 166 Self {
163 inner: mutex::BlockingMutex::new(cordyceps::Stack::new()), 167 inner: critical_section::Mutex::new(core::cell::RefCell::new(cordyceps::Stack::new())),
164 } 168 }
165 } 169 }
166 170
167 fn push_was_empty(&self, item: T::Handle) -> bool { 171 fn push_was_empty(&self, item: T::Handle, token: super::state::Token) -> bool {
168 self.inner.with_lock(|stack| { 172 let mut guard = self.inner.borrow_ref_mut(token);
169 let is_empty = stack.is_empty(); 173 let is_empty = guard.is_empty();
170 stack.push(item); 174 guard.push(item);
171 is_empty 175 is_empty
172 })
173 } 176 }
174 177
175 fn take_all(&self) -> cordyceps::Stack<T> { 178 fn take_all(&self) -> cordyceps::Stack<T> {
176 self.inner.with_lock(|stack| stack.take_all()) 179 critical_section::with(|cs| {
180 let mut guard = self.inner.borrow_ref_mut(cs);
181 guard.take_all()
182 })
177 } 183 }
178} 184}