From da0c28c0b6fa73676db35f97196afd9bcfa5fa47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Raz=20Guzm=C3=A1n=20Macedo?= Date: Mon, 6 Nov 2023 11:41:47 -0600 Subject: [PATCH 1/3] use Waker::clone_from internally --- src/utils/wakers/array/readiness_array.rs | 5 ++++- src/utils/wakers/vec/readiness_vec.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/wakers/array/readiness_array.rs b/src/utils/wakers/array/readiness_array.rs index c7e2157..dd50ae7 100644 --- a/src/utils/wakers/array/readiness_array.rs +++ b/src/utils/wakers/array/readiness_array.rs @@ -62,6 +62,9 @@ impl ReadinessArray { /// 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()), + } } } diff --git a/src/utils/wakers/vec/readiness_vec.rs b/src/utils/wakers/vec/readiness_vec.rs index 76be854..65fdc24 100644 --- a/src/utils/wakers/vec/readiness_vec.rs +++ b/src/utils/wakers/vec/readiness_vec.rs @@ -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. From dbbd00c17a53e61142a9b9486260b1bd742b41bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Raz=20Guzm=C3=A1n=20Macedo?= Date: Mon, 6 Nov 2023 18:45:03 -0600 Subject: [PATCH 2/3] add clone_from for channel --- src/utils/channel.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/channel.rs b/src/utils/channel.rs index d3a6709..9db615e 100644 --- a/src/utils/channel.rs +++ b/src/utils/channel.rs @@ -30,7 +30,10 @@ impl Stream for LocalReceiver { 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 } } From dd86d87908d31a768864bfb05424aa33f9bed576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Raz=20Guzm=C3=A1n=20Macedo?= Date: Mon, 6 Nov 2023 18:47:42 -0600 Subject: [PATCH 3/3] add Waker::clone_from to channel.rs --- src/utils/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/channel.rs b/src/utils/channel.rs index 9db615e..07081df 100644 --- a/src/utils/channel.rs +++ b/src/utils/channel.rs @@ -32,7 +32,7 @@ impl Stream for LocalReceiver { } else { match &mut channel.waker { Some(prev) => prev.clone_from(cx.waker()), - None => channel.waker = Some(cx.waker().clone()) + None => channel.waker = Some(cx.waker().clone()), } Poll::Pending }