aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/spawner.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/spawner.rs')
-rw-r--r--embassy-executor/src/spawner.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs
index 271606244..bc243bee7 100644
--- a/embassy-executor/src/spawner.rs
+++ b/embassy-executor/src/spawner.rs
@@ -92,7 +92,9 @@ impl Spawner {
92 pub async fn for_current_executor() -> Self { 92 pub async fn for_current_executor() -> Self {
93 poll_fn(|cx| { 93 poll_fn(|cx| {
94 let task = raw::task_from_waker(cx.waker()); 94 let task = raw::task_from_waker(cx.waker());
95 let executor = unsafe { task.header().executor.get().unwrap_unchecked() }; 95 let executor = raw::state::locked(|l| {
96 unsafe { task.header().executor.get(l).as_ref().unwrap_unchecked() }
97 });
96 let executor = unsafe { raw::Executor::wrap(executor) }; 98 let executor = unsafe { raw::Executor::wrap(executor) };
97 Poll::Ready(Self::new(executor)) 99 Poll::Ready(Self::new(executor))
98 }) 100 })
@@ -164,7 +166,9 @@ impl SendSpawner {
164 pub async fn for_current_executor() -> Self { 166 pub async fn for_current_executor() -> Self {
165 poll_fn(|cx| { 167 poll_fn(|cx| {
166 let task = raw::task_from_waker(cx.waker()); 168 let task = raw::task_from_waker(cx.waker());
167 let executor = unsafe { task.header().executor.get().unwrap_unchecked() }; 169 let executor = raw::state::locked(|l| {
170 unsafe { task.header().executor.get(l).as_ref().unwrap_unchecked() }
171 });
168 Poll::Ready(Self::new(executor)) 172 Poll::Ready(Self::new(executor))
169 }) 173 })
170 .await 174 .await