diff --git a/src/atomic_waiter.rs b/src/atomic_waiter.rs index d29ceb9..6343643 100644 --- a/src/atomic_waiter.rs +++ b/src/atomic_waiter.rs @@ -4,7 +4,6 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::task::{Context, Poll}; use futures::task::AtomicWaker; -use futures::Stream; /// Thin wrapper over [`futures::task::AtomicWaker`]. This represents a /// Send + Sync Future that can be completed by calling its wake() method. @@ -78,10 +77,3 @@ impl Future for AtomicWaiter { self.poll_const(cx) } } - -impl Stream for AtomicWaiter { - type Item = (); - fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - self.poll(cx).map(Some) - } -} diff --git a/src/lib.rs b/src/lib.rs index 0919deb..0efde92 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,8 +7,6 @@ use core::ptr::null_mut; use core::sync::atomic::{AtomicBool, AtomicPtr, Ordering}; use core::task::{Context, Poll}; -use futures::Stream; - pub mod atomic_waiter; use atomic_waiter::AtomicWaiter; @@ -221,28 +219,17 @@ impl<'m, const M: usize, T> Future for BorrowMutexLender<'m, M, T> { // And the same lend_waiter is polled in LendGuard, which could have // consumed both of those wakes. Before we start endlessly polling now, // check if we're ready - if !self.mutex.borrowers.is_empty() { - return Poll::Ready(()); - } - - if self.mutex.lend_waiter.poll_const(cx) == Poll::Pending { - return Poll::Pending; + #[allow(clippy::collapsible_if)] + if self.mutex.borrowers.is_empty() { + if self.mutex.lend_waiter.poll_const(cx) == Poll::Pending { + return Poll::Pending; + } } - // even if dropped on the borrowing side, borrowers stay in the queue - // until us (the lender) pops them - assert!(!self.mutex.borrowers.is_empty()); Poll::Ready(()) } } -impl<'m, const M: usize, T> Stream for BorrowMutexLender<'m, M, T> { - type Item = (); - fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - self.poll(cx).map(Some) - } -} - pub struct BorrowMutexLendGuard<'l, const M: usize, T> { mutex: *const BorrowMutex, borrow: &'l BorrowMutexRef,