diff options
| author | Dániel Buga <[email protected]> | 2024-12-17 18:37:17 +0100 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2024-12-17 18:37:17 +0100 |
| commit | a011f487690465f8ae64fd74f4c51a8be3979890 (patch) | |
| tree | d6a0a3b5ce891a4e56df26076ed676d6dd59e62b /embassy-executor/src | |
| parent | 7d5fbe26c955bae4bd394d1092702bd81f849c9b (diff) | |
Make poll_to_despawn non-generic
Diffstat (limited to 'embassy-executor/src')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 5df5ca9e1..39d2d73ab 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -161,6 +161,12 @@ pub struct TaskStorage<F: Future + 'static> { | |||
| 161 | future: UninitCell<F>, // Valid if STATE_SPAWNED | 161 | future: UninitCell<F>, // Valid if STATE_SPAWNED |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | unsafe fn poll_to_despawn(p: TaskRef) { | ||
| 165 | // The task's future has already been dropped, we just mark it as `!SPAWNED`. | ||
| 166 | let this = p.header(); | ||
| 167 | this.state.despawn(); | ||
| 168 | } | ||
| 169 | |||
| 164 | impl<F: Future + 'static> TaskStorage<F> { | 170 | impl<F: Future + 'static> TaskStorage<F> { |
| 165 | const NEW: Self = Self::new(); | 171 | const NEW: Self = Self::new(); |
| 166 | 172 | ||
| @@ -201,12 +207,6 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 201 | } | 207 | } |
| 202 | } | 208 | } |
| 203 | 209 | ||
| 204 | unsafe fn poll_to_despawn(p: TaskRef) { | ||
| 205 | // The task's future has already been dropped, we just mark it as `!SPAWNED`. | ||
| 206 | let this = &*p.as_ptr().cast::<TaskStorage<F>>(); | ||
| 207 | this.raw.state.despawn(); | ||
| 208 | } | ||
| 209 | |||
| 210 | unsafe fn poll(p: TaskRef) { | 210 | unsafe fn poll(p: TaskRef) { |
| 211 | let this = &*p.as_ptr().cast::<TaskStorage<F>>(); | 211 | let this = &*p.as_ptr().cast::<TaskStorage<F>>(); |
| 212 | 212 | ||
| @@ -223,7 +223,7 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 223 | 223 | ||
| 224 | // We replace the poll_fn with a despawn function, so that the task is cleaned up | 224 | // We replace the poll_fn with a despawn function, so that the task is cleaned up |
| 225 | // when the executor polls it next. | 225 | // when the executor polls it next. |
| 226 | this.raw.poll_fn.set(Some(Self::poll_to_despawn)); | 226 | this.raw.poll_fn.set(Some(poll_to_despawn)); |
| 227 | } | 227 | } |
| 228 | Poll::Pending => {} | 228 | Poll::Pending => {} |
| 229 | } | 229 | } |
