Skip to content

Commit

Permalink
Don't force a wake to despawn
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Dec 17, 2024
1 parent a011f48 commit 2522b12
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
3 changes: 1 addition & 2 deletions embassy-executor/src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,14 @@ impl<F: Future + 'static> TaskStorage<F> {
let mut cx = Context::from_waker(&waker);
match future.poll(&mut cx) {
Poll::Ready(_) => {
waker.wake_by_ref();

// As the future has finished and this function will not be called
// again, we can safely drop the future here.
this.future.drop_in_place();

// We replace the poll_fn with a despawn function, so that the task is cleaned up
// when the executor polls it next.
this.raw.poll_fn.set(Some(poll_to_despawn));
this.raw.state.despawn();
}
Poll::Pending => {}
}
Expand Down
3 changes: 0 additions & 3 deletions embassy-executor/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ fn executor_task() {
&[
"pend", // spawning a task pends the executor
"poll task1", // poll only once.
"pend", // task is done, wakes itself to exit
]
)
}
Expand Down Expand Up @@ -180,7 +179,6 @@ fn waking_after_completion_does_not_poll() {
"pend", // manual wake, single pend for two wakes
"pend", // respawning a task pends the executor
"poll task1", //
"pend", // task is done, wakes itself to exit
]
)
}
Expand Down Expand Up @@ -268,7 +266,6 @@ fn waking_with_old_waker_after_respawn() {
"yield_now", //
"pend", // manual wake, gets cleared by poll
"poll task1", //
"pend", // task is done, wakes itself to exit
]
);
}
Expand Down

0 comments on commit 2522b12

Please sign in to comment.