aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
-rw-r--r--embassy-executor/src/raw/mod.rs6
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 }