Skip to content

Commit

Permalink
Merge pull request #161 from miguelraz/main
Browse files Browse the repository at this point in the history
use Waker::clone_from internally
  • Loading branch information
yoshuawuyts authored Nov 7, 2023
2 parents 112b40e + dd86d87 commit eed67b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/utils/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ impl<T> Stream for LocalReceiver<T> {
if channel.closed {
Poll::Ready(None)
} else {
channel.waker = Some(cx.waker().clone());
match &mut channel.waker {
Some(prev) => prev.clone_from(cx.waker()),
None => channel.waker = Some(cx.waker().clone()),
}
Poll::Pending
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/wakers/array/readiness_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ impl<const N: usize> ReadinessArray<N> {
/// Set the parent `Waker`. This needs to be called at the start of every
/// `poll` function.
pub(crate) fn set_waker(&mut self, parent_waker: &Waker) {
self.parent_waker = Some(parent_waker.clone());
match &mut self.parent_waker {
Some(prev) => prev.clone_from(parent_waker),
None => self.parent_waker = Some(parent_waker.clone()),
}
}
}
5 changes: 4 additions & 1 deletion src/utils/wakers/vec/readiness_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ impl ReadinessVec {
/// Set the parent `Waker`. This needs to be called at the start of every
/// `poll` function.
pub(crate) fn set_waker(&mut self, parent_waker: &Waker) {
self.parent_waker = Some(parent_waker.clone());
match &mut self.parent_waker {
Some(prev) => prev.clone_from(parent_waker),
None => self.parent_waker = Some(parent_waker.clone()),
}
}

/// Resize `readiness` to the new length.
Expand Down

0 comments on commit eed67b3

Please sign in to comment.