aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDániel Buga <[email protected]>2024-12-17 18:46:32 +0100
committerDániel Buga <[email protected]>2024-12-17 18:47:56 +0100
commit2ca374fc9c0d0abe579716d1a7c2dc0724321ee7 (patch)
tree65b7f014433445f82e46612d5df18bbef4bd92fa
parenta011f487690465f8ae64fd74f4c51a8be3979890 (diff)
Don't force a wake to despawn
-rw-r--r--embassy-executor/src/raw/mod.rs6
-rw-r--r--embassy-executor/tests/test.rs3
2 files changed, 4 insertions, 5 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 }
diff --git a/embassy-executor/tests/test.rs b/embassy-executor/tests/test.rs
index d8c5a6ae3..78c49c071 100644
--- a/embassy-executor/tests/test.rs
+++ b/embassy-executor/tests/test.rs
@@ -69,7 +69,6 @@ fn executor_task() {
69 &[ 69 &[
70 "pend", // spawning a task pends the executor 70 "pend", // spawning a task pends the executor
71 "poll task1", // poll only once. 71 "poll task1", // poll only once.
72 "pend", // task is done, wakes itself to exit
73 ] 72 ]
74 ) 73 )
75} 74}
@@ -180,7 +179,6 @@ fn waking_after_completion_does_not_poll() {
180 "pend", // manual wake, single pend for two wakes 179 "pend", // manual wake, single pend for two wakes
181 "pend", // respawning a task pends the executor 180 "pend", // respawning a task pends the executor
182 "poll task1", // 181 "poll task1", //
183 "pend", // task is done, wakes itself to exit
184 ] 182 ]
185 ) 183 )
186} 184}
@@ -268,7 +266,6 @@ fn waking_with_old_waker_after_respawn() {
268 "yield_now", // 266 "yield_now", //
269 "pend", // manual wake, gets cleared by poll 267 "pend", // manual wake, gets cleared by poll
270 "poll task1", // 268 "poll task1", //
271 "pend", // task is done, wakes itself to exit
272 ] 269 ]
273 ); 270 );
274} 271}