aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/spawner.rs
diff options
context:
space:
mode:
authorGrant Miller <[email protected]>2023-01-31 17:49:18 -0600
committerGrant Miller <[email protected]>2023-01-31 18:59:03 -0600
commitfb1946be7fa38eecb36711a1257f89dae3714b61 (patch)
tree4ccfd365854f55ad638762fb4f0c23ee2e3576b5 /embassy-executor/src/spawner.rs
parenta697f1517a9c54ba042bbf70e0b2ed762d300471 (diff)
Replace the pointer in `TaskHeader` with an `Option<&Executor>`
Diffstat (limited to 'embassy-executor/src/spawner.rs')
-rw-r--r--embassy-executor/src/spawner.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs
index 650ea06cb..7c0a0183c 100644
--- a/embassy-executor/src/spawner.rs
+++ b/embassy-executor/src/spawner.rs
@@ -89,10 +89,10 @@ impl Spawner {
89 /// 89 ///
90 /// Panics if the current executor is not an Embassy executor. 90 /// Panics if the current executor is not an Embassy executor.
91 pub async fn for_current_executor() -> Self { 91 pub async fn for_current_executor() -> Self {
92 poll_fn(|cx| unsafe { 92 poll_fn(|cx| {
93 let task = raw::task_from_waker(cx.waker()); 93 let task = raw::task_from_waker(cx.waker());
94 let executor = task.header().executor.get(); 94 let executor = unsafe { task.header().executor.get().unwrap_unchecked() };
95 Poll::Ready(Self::new(&*executor)) 95 Poll::Ready(Self::new(executor))
96 }) 96 })
97 .await 97 .await
98 } 98 }
@@ -165,10 +165,10 @@ impl SendSpawner {
165 /// 165 ///
166 /// Panics if the current executor is not an Embassy executor. 166 /// Panics if the current executor is not an Embassy executor.
167 pub async fn for_current_executor() -> Self { 167 pub async fn for_current_executor() -> Self {
168 poll_fn(|cx| unsafe { 168 poll_fn(|cx| {
169 let task = raw::task_from_waker(cx.waker()); 169 let task = raw::task_from_waker(cx.waker());
170 let executor = task.header().executor.get(); 170 let executor = unsafe { task.header().executor.get().unwrap_unchecked() };
171 Poll::Ready(Self::new(&*executor)) 171 Poll::Ready(Self::new(executor))
172 }) 172 })
173 .await 173 .await
174 } 174 }