diff options
| author | Dániel Buga <[email protected]> | 2024-12-17 18:46:32 +0100 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2024-12-17 18:47:56 +0100 |
| commit | 2ca374fc9c0d0abe579716d1a7c2dc0724321ee7 (patch) | |
| tree | 65b7f014433445f82e46612d5df18bbef4bd92fa /embassy-executor/src | |
| parent | a011f487690465f8ae64fd74f4c51a8be3979890 (diff) | |
Don't force a wake to despawn
Diffstat (limited to 'embassy-executor/src')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 39d2d73ab..4a4ecf603 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -215,8 +215,6 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 215 | let mut cx = Context::from_waker(&waker); | 215 | let mut cx = Context::from_waker(&waker); |
| 216 | match future.poll(&mut cx) { | 216 | match future.poll(&mut cx) { |
| 217 | Poll::Ready(_) => { | 217 | Poll::Ready(_) => { |
| 218 | waker.wake_by_ref(); | ||
| 219 | |||
| 220 | // As the future has finished and this function will not be called | 218 | // As the future has finished and this function will not be called |
| 221 | // again, we can safely drop the future here. | 219 | // again, we can safely drop the future here. |
| 222 | this.future.drop_in_place(); | 220 | this.future.drop_in_place(); |
| @@ -224,6 +222,10 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 224 | // We replace the poll_fn with a despawn function, so that the task is cleaned up | 222 | // We replace the poll_fn with a despawn function, so that the task is cleaned up |
| 225 | // when the executor polls it next. | 223 | // when the executor polls it next. |
| 226 | this.raw.poll_fn.set(Some(poll_to_despawn)); | 224 | this.raw.poll_fn.set(Some(poll_to_despawn)); |
| 225 | |||
| 226 | // Make sure we despawn last, so that other threads can only spawn the task | ||
| 227 | // after we're done with it. | ||
| 228 | this.raw.state.despawn(); | ||
| 227 | } | 229 | } |
| 228 | Poll::Pending => {} | 230 | Poll::Pending => {} |
| 229 | } | 231 | } |
