diff options
| author | Dániel Buga <[email protected]> | 2024-12-30 12:13:13 +0100 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2024-12-30 12:13:13 +0100 |
| commit | 44217aa0924e7590aa0afabdf17babd5c2ea5b82 (patch) | |
| tree | e42f5d02f9b560610b870d802cf390518180c3c6 /embassy-executor/src | |
| parent | a4f8fddd696ca2e3705827ba4b3806cbadcb3134 (diff) | |
Desugar some async fns
Diffstat (limited to 'embassy-executor/src')
| -rw-r--r-- | embassy-executor/src/spawner.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs index 41320d4c3..ce24589bf 100644 --- a/embassy-executor/src/spawner.rs +++ b/embassy-executor/src/spawner.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::future::poll_fn; | 1 | use core::future::{poll_fn, Future}; |
| 2 | use core::marker::PhantomData; | 2 | use core::marker::PhantomData; |
| 3 | use core::mem; | 3 | use core::mem; |
| 4 | use core::sync::atomic::Ordering; | 4 | use core::sync::atomic::Ordering; |
| @@ -100,7 +100,7 @@ impl Spawner { | |||
| 100 | /// # Panics | 100 | /// # Panics |
| 101 | /// | 101 | /// |
| 102 | /// Panics if the current executor is not an Embassy executor. | 102 | /// Panics if the current executor is not an Embassy executor. |
| 103 | pub async fn for_current_executor() -> Self { | 103 | pub fn for_current_executor() -> impl Future<Output = Self> { |
| 104 | poll_fn(|cx| { | 104 | poll_fn(|cx| { |
| 105 | let task = raw::task_from_waker(cx.waker()); | 105 | let task = raw::task_from_waker(cx.waker()); |
| 106 | let executor = unsafe { | 106 | let executor = unsafe { |
| @@ -113,7 +113,6 @@ impl Spawner { | |||
| 113 | let executor = unsafe { raw::Executor::wrap(executor) }; | 113 | let executor = unsafe { raw::Executor::wrap(executor) }; |
| 114 | Poll::Ready(Self::new(executor)) | 114 | Poll::Ready(Self::new(executor)) |
| 115 | }) | 115 | }) |
| 116 | .await | ||
| 117 | } | 116 | } |
| 118 | 117 | ||
| 119 | /// Spawn a task into an executor. | 118 | /// Spawn a task into an executor. |
| @@ -178,7 +177,7 @@ impl SendSpawner { | |||
| 178 | /// # Panics | 177 | /// # Panics |
| 179 | /// | 178 | /// |
| 180 | /// Panics if the current executor is not an Embassy executor. | 179 | /// Panics if the current executor is not an Embassy executor. |
| 181 | pub async fn for_current_executor() -> Self { | 180 | pub fn for_current_executor() -> impl Future<Output = Self> { |
| 182 | poll_fn(|cx| { | 181 | poll_fn(|cx| { |
| 183 | let task = raw::task_from_waker(cx.waker()); | 182 | let task = raw::task_from_waker(cx.waker()); |
| 184 | let executor = unsafe { | 183 | let executor = unsafe { |
| @@ -190,7 +189,6 @@ impl SendSpawner { | |||
| 190 | }; | 189 | }; |
| 191 | Poll::Ready(Self::new(executor)) | 190 | Poll::Ready(Self::new(executor)) |
| 192 | }) | 191 | }) |
| 193 | .await | ||
| 194 | } | 192 | } |
| 195 | 193 | ||
| 196 | /// Spawn a task into an executor. | 194 | /// Spawn a task into an executor. |
