aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/spawner.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-02-03 06:33:22 +0000
committerGitHub <[email protected]>2023-02-03 06:33:22 +0000
commit7d8e6649b7d3364d363cacf9696bd9f40f6881a8 (patch)
tree91652614a35a512f518ecbd88c05061a07d1ccd6 /embassy-executor/src/spawner.rs
parent662a02a557457f09c4f9b1f5320c657991a65fc6 (diff)
parent791fbb3ca0caf81882f67caea9e71adf43496261 (diff)
Merge #1187
1187: executor: Minor refactoring r=Dirbaio a=GrantM11235 The third commit may be slightly more controversial than the first two. Personally, I think it makes the code more readable and easier to reason about, but I can drop it if you disagree. Co-authored-by: Grant Miller <[email protected]>
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 }