Skip to content

Commit eed67b3

Browse files
authored
Merge pull request #161 from miguelraz/main
use Waker::clone_from internally
2 parents 112b40e + dd86d87 commit eed67b3

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/utils/channel.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ impl<T> Stream for LocalReceiver<T> {
3030
if channel.closed {
3131
Poll::Ready(None)
3232
} else {
33-
channel.waker = Some(cx.waker().clone());
33+
match &mut channel.waker {
34+
Some(prev) => prev.clone_from(cx.waker()),
35+
None => channel.waker = Some(cx.waker().clone()),
36+
}
3437
Poll::Pending
3538
}
3639
}

src/utils/wakers/array/readiness_array.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ impl<const N: usize> ReadinessArray<N> {
6262
/// Set the parent `Waker`. This needs to be called at the start of every
6363
/// `poll` function.
6464
pub(crate) fn set_waker(&mut self, parent_waker: &Waker) {
65-
self.parent_waker = Some(parent_waker.clone());
65+
match &mut self.parent_waker {
66+
Some(prev) => prev.clone_from(parent_waker),
67+
None => self.parent_waker = Some(parent_waker.clone()),
68+
}
6669
}
6770
}

src/utils/wakers/vec/readiness_vec.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ impl ReadinessVec {
7474
/// Set the parent `Waker`. This needs to be called at the start of every
7575
/// `poll` function.
7676
pub(crate) fn set_waker(&mut self, parent_waker: &Waker) {
77-
self.parent_waker = Some(parent_waker.clone());
77+
match &mut self.parent_waker {
78+
Some(prev) => prev.clone_from(parent_waker),
79+
None => self.parent_waker = Some(parent_waker.clone()),
80+
}
7881
}
7982

8083
/// Resize `readiness` to the new length.

0 commit comments

Comments
 (0)