Skip to content

Commit a1db83d

Browse files
committed
AtomicWaker: take and wake
1 parent 52e4c7c commit a1db83d

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

embassy-executor/tests/test.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ fn waking_after_completion_does_not_poll() {
156156
let (executor, trace) = setup();
157157
executor.spawner().spawn(task1(trace.clone(), waker)).unwrap();
158158

159-
unsafe { executor.poll() };
160-
waker.wake();
159+
// Task registers waker, then exits
161160
unsafe { executor.poll() };
162161

163162
// Exited task may be waken but is not polled
@@ -176,7 +175,6 @@ fn waking_after_completion_does_not_poll() {
176175
"pend", // spawning a task pends the executor
177176
"poll task1", //
178177
"pend", // manual wake, gets cleared by poll
179-
"pend", // manual wake, single pend for two wakes
180178
"pend", // respawning a task pends the executor
181179
"poll task1", //
182180
]

embassy-sync/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- AtomicWaker now drops the Waker after waking it.
11+
1012
## 0.6.2 - 2025-01-15
1113

1214
- Add dynamic dispatch variant of `Pipe`.

embassy-sync/src/waitqueue/atomic_waker.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ impl<M: RawMutex> GenericAtomicWaker<M> {
3333
/// Wake the registered waker, if any.
3434
pub fn wake(&self) {
3535
self.waker.lock(|cell| {
36-
if let Some(w) = cell.replace(None) {
37-
w.wake_by_ref();
38-
cell.set(Some(w));
36+
if let Some(w) = cell.take() {
37+
w.wake();
3938
}
4039
})
4140
}

0 commit comments

Comments
 (0)