diff options
| author | Rasmus Melchior Jacobsen <[email protected]> | 2023-03-29 14:10:33 +0200 |
|---|---|---|
| committer | Rasmus Melchior Jacobsen <[email protected]> | 2023-03-29 14:10:33 +0200 |
| commit | a0d089536a213ec093ed5e440e3d9a1e8fc3e9a2 (patch) | |
| tree | 27e154937e469fc0868616a1d6718314f19961db /embassy-executor/src/spawner.rs | |
| parent | 15e17472207fe587c38ba6cd2c2214ae4e88ee32 (diff) | |
| parent | 0bbc3a3d81f243b0249bf231a5b6cd53772b28e0 (diff) | |
Merge branch 'flash-regions' of https://github.com/rmja/embassy into flash-regions
Diffstat (limited to 'embassy-executor/src/spawner.rs')
| -rw-r--r-- | embassy-executor/src/spawner.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs index 7c0a0183c..2b6224045 100644 --- a/embassy-executor/src/spawner.rs +++ b/embassy-executor/src/spawner.rs | |||
| @@ -92,6 +92,7 @@ impl Spawner { | |||
| 92 | poll_fn(|cx| { | 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 = unsafe { task.header().executor.get().unwrap_unchecked() }; | 94 | let executor = unsafe { task.header().executor.get().unwrap_unchecked() }; |
| 95 | let executor = unsafe { raw::Executor::wrap(executor) }; | ||
| 95 | Poll::Ready(Self::new(executor)) | 96 | Poll::Ready(Self::new(executor)) |
| 96 | }) | 97 | }) |
| 97 | .await | 98 | .await |
| @@ -130,9 +131,7 @@ impl Spawner { | |||
| 130 | /// spawner to other threads, but the spawner loses the ability to spawn | 131 | /// spawner to other threads, but the spawner loses the ability to spawn |
| 131 | /// non-Send tasks. | 132 | /// non-Send tasks. |
| 132 | pub fn make_send(&self) -> SendSpawner { | 133 | pub fn make_send(&self) -> SendSpawner { |
| 133 | SendSpawner { | 134 | SendSpawner::new(&self.executor.inner) |
| 134 | executor: self.executor, | ||
| 135 | } | ||
| 136 | } | 135 | } |
| 137 | } | 136 | } |
| 138 | 137 | ||
| @@ -145,14 +144,11 @@ impl Spawner { | |||
| 145 | /// If you want to spawn non-Send tasks, use [Spawner]. | 144 | /// If you want to spawn non-Send tasks, use [Spawner]. |
| 146 | #[derive(Copy, Clone)] | 145 | #[derive(Copy, Clone)] |
| 147 | pub struct SendSpawner { | 146 | pub struct SendSpawner { |
| 148 | executor: &'static raw::Executor, | 147 | executor: &'static raw::SyncExecutor, |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | unsafe impl Send for SendSpawner {} | ||
| 152 | unsafe impl Sync for SendSpawner {} | ||
| 153 | |||
| 154 | impl SendSpawner { | 150 | impl SendSpawner { |
| 155 | pub(crate) fn new(executor: &'static raw::Executor) -> Self { | 151 | pub(crate) fn new(executor: &'static raw::SyncExecutor) -> Self { |
| 156 | Self { executor } | 152 | Self { executor } |
| 157 | } | 153 | } |
| 158 | 154 | ||
