From fb8136549f458d0c6e132c49c3d66eed79e62381 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 9 Oct 2019 13:52:19 -0700 Subject: [PATCH] Rename oneshot:Sender::poll_cancel to poll_canceled In most other places, `poll_action` means that 'action' is happening asynchronously. The name `poll_cancel` implies that the call will cancel the oneshot, but really we just wish to poll if it *has been* canceled. --- futures-channel/src/oneshot.rs | 14 +++++++------- futures-channel/tests/oneshot.rs | 14 +++++++------- futures-util/src/future/remote_handle.rs | 2 +- futures/tests/ready_queue.rs | 12 ++++++------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/futures-channel/src/oneshot.rs b/futures-channel/src/oneshot.rs index 5c9b3fbbfb..ed552509d1 100644 --- a/futures-channel/src/oneshot.rs +++ b/futures-channel/src/oneshot.rs @@ -43,7 +43,7 @@ struct Inner { /// unlocked and ready to be inspected. /// /// For `Sender` if this is `true` then the oneshot has gone away and it - /// can return ready from `poll_cancel`. + /// can return ready from `poll_canceled`. complete: AtomicBool, /// The actual data being transferred as part of this `Receiver`. This is @@ -64,7 +64,7 @@ struct Inner { rx_task: Lock>, /// Like `rx_task` above, except for the task blocked in - /// `Sender::poll_cancel`. Additionally, `Lock` cannot be `UnsafeCell`. + /// `Sender::poll_canceled`. Additionally, `Lock` cannot be `UnsafeCell`. tx_task: Lock>, } @@ -153,7 +153,7 @@ impl Inner { } } - fn poll_cancel(&self, cx: &mut Context<'_>) -> Poll<()> { + fn poll_canceled(&self, cx: &mut Context<'_>) -> Poll<()> { // Fast path up first, just read the flag and see if our other half is // gone. This flag is set both in our destructor and the oneshot // destructor, but our destructor hasn't run yet so if it's set then the @@ -298,7 +298,7 @@ impl Inner { fn drop_rx(&self) { // Indicate to the `Sender` that we're done, so any future calls to - // `poll_cancel` are weeded out. + // `poll_canceled` are weeded out. self.complete.store(true, SeqCst); // If we've blocked a task then there's no need for it to stick around, @@ -354,14 +354,14 @@ impl Sender { /// alive and may be able to receive a message if sent. The current task, /// however, is scheduled to receive a notification if the corresponding /// `Receiver` goes away. - pub fn poll_cancel(&mut self, cx: &mut Context<'_>) -> Poll<()> { - self.inner.poll_cancel(cx) + pub fn poll_canceled(&mut self, cx: &mut Context<'_>) -> Poll<()> { + self.inner.poll_canceled(cx) } /// Tests to see whether this `Sender`'s corresponding `Receiver` /// has been dropped. /// - /// Unlike [`poll_cancel`](Sender::poll_cancel), this function does not + /// Unlike [`poll_canceled`](Sender::poll_canceled), this function does not /// enqueue a task for wakeup upon cancellation, but merely reports the /// current state, which may be subject to concurrent modification. pub fn is_canceled(&self) -> bool { diff --git a/futures-channel/tests/oneshot.rs b/futures-channel/tests/oneshot.rs index b36d25df60..e6bc3f5fe9 100644 --- a/futures-channel/tests/oneshot.rs +++ b/futures-channel/tests/oneshot.rs @@ -12,11 +12,11 @@ fn smoke_poll() { let (mut tx, rx) = oneshot::channel::(); let mut rx = Some(rx); let f = poll_fn(|cx| { - assert!(tx.poll_cancel(cx).is_pending()); - assert!(tx.poll_cancel(cx).is_pending()); + assert!(tx.poll_canceled(cx).is_pending()); + assert!(tx.poll_canceled(cx).is_pending()); drop(rx.take()); - assert!(tx.poll_cancel(cx).is_ready()); - assert!(tx.poll_cancel(cx).is_ready()); + assert!(tx.poll_canceled(cx).is_ready()); + assert!(tx.poll_canceled(cx).is_ready()); Poll::Ready(()) }); @@ -42,7 +42,7 @@ impl Future for WaitForCancel { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - self.tx.poll_cancel(cx) + self.tx.poll_canceled(cx) } } @@ -72,7 +72,7 @@ fn cancel_lots() { fn cancel_after_sender_drop_doesnt_notify() { let (mut tx, rx) = oneshot::channel::(); let mut cx = Context::from_waker(panic_waker_ref()); - assert_eq!(tx.poll_cancel(&mut cx), Poll::Pending); + assert_eq!(tx.poll_canceled(&mut cx), Poll::Pending); drop(tx); drop(rx); } @@ -86,7 +86,7 @@ fn close() { Poll::Ready(Err(_)) => {}, _ => panic!(), }; - assert!(tx.poll_cancel(cx).is_ready()); + assert!(tx.poll_canceled(cx).is_ready()); Poll::Ready(()) })); } diff --git a/futures-util/src/future/remote_handle.rs b/futures-util/src/future/remote_handle.rs index e3223c6c24..4e30eededd 100644 --- a/futures-util/src/future/remote_handle.rs +++ b/futures-util/src/future/remote_handle.rs @@ -80,7 +80,7 @@ impl Future for Remote { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { - if let Poll::Ready(_) = self.as_mut().tx().as_mut().unwrap().poll_cancel(cx) { + if let Poll::Ready(_) = self.as_mut().tx().as_mut().unwrap().poll_canceled(cx) { if !self.keep_running.load(Ordering::SeqCst) { // Cancelled, bail out return Poll::Ready(()) diff --git a/futures/tests/ready_queue.rs b/futures/tests/ready_queue.rs index ae0b7c356d..8005800514 100644 --- a/futures/tests/ready_queue.rs +++ b/futures/tests/ready_queue.rs @@ -81,15 +81,15 @@ fn dropping_ready_queue() { { let cx = &mut noop_context(); - assert!(!tx1.poll_cancel(cx).is_ready()); - assert!(!tx2.poll_cancel(cx).is_ready()); - assert!(!tx3.poll_cancel(cx).is_ready()); + assert!(!tx1.poll_canceled(cx).is_ready()); + assert!(!tx2.poll_canceled(cx).is_ready()); + assert!(!tx3.poll_canceled(cx).is_ready()); drop(queue); - assert!(tx1.poll_cancel(cx).is_ready()); - assert!(tx2.poll_cancel(cx).is_ready()); - assert!(tx3.poll_cancel(cx).is_ready()); + assert!(tx1.poll_canceled(cx).is_ready()); + assert!(tx2.poll_canceled(cx).is_ready()); + assert!(tx3.poll_canceled(cx).is_ready()); } })); }