From 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:39 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/futures-channel/src/mpsc/mod.rs | 71 +++++++++++++++++++++++++++----- vendor/futures-channel/src/mpsc/queue.rs | 2 - vendor/futures-channel/src/oneshot.rs | 4 +- 3 files changed, 63 insertions(+), 14 deletions(-) (limited to 'vendor/futures-channel/src') diff --git a/vendor/futures-channel/src/mpsc/mod.rs b/vendor/futures-channel/src/mpsc/mod.rs index 44834b7c9..cf45fe77f 100644 --- a/vendor/futures-channel/src/mpsc/mod.rs +++ b/vendor/futures-channel/src/mpsc/mod.rs @@ -94,13 +94,11 @@ mod queue; #[cfg(feature = "sink")] mod sink_impl; -#[derive(Debug)] struct UnboundedSenderInner { // Channel state shared between the sender and receiver. inner: Arc>, } -#[derive(Debug)] struct BoundedSenderInner { // Channel state shared between the sender and receiver. inner: Arc>, @@ -122,13 +120,11 @@ impl Unpin for BoundedSenderInner {} /// The transmission end of a bounded mpsc channel. /// /// This value is created by the [`channel`](channel) function. -#[derive(Debug)] pub struct Sender(Option>); /// The transmission end of an unbounded mpsc channel. /// /// This value is created by the [`unbounded`](unbounded) function. -#[derive(Debug)] pub struct UnboundedSender(Option>); trait AssertKinds: Send + Sync + Clone {} @@ -137,7 +133,6 @@ impl AssertKinds for UnboundedSender {} /// The receiving end of a bounded mpsc channel. /// /// This value is created by the [`channel`](channel) function. -#[derive(Debug)] pub struct Receiver { inner: Option>>, } @@ -145,7 +140,6 @@ pub struct Receiver { /// The receiving end of an unbounded mpsc channel. /// /// This value is created by the [`unbounded`](unbounded) function. -#[derive(Debug)] pub struct UnboundedReceiver { inner: Option>>, } @@ -261,7 +255,6 @@ impl fmt::Display for TryRecvError { impl std::error::Error for TryRecvError {} -#[derive(Debug)] struct UnboundedInner { // Internal channel state. Consists of the number of messages stored in the // channel as well as a flag signalling that the channel is closed. @@ -277,7 +270,6 @@ struct UnboundedInner { recv_task: AtomicWaker, } -#[derive(Debug)] struct BoundedInner { // Max buffer size of the channel. If `None` then the channel is unbounded. buffer: usize, @@ -300,7 +292,7 @@ struct BoundedInner { } // Struct representation of `Inner::state`. -#[derive(Debug, Clone, Copy)] +#[derive(Clone, Copy)] struct State { // `true` when the channel is open is_open: bool, @@ -324,7 +316,6 @@ const MAX_CAPACITY: usize = !(OPEN_MASK); const MAX_BUFFER: usize = MAX_CAPACITY >> 1; // Sent to the consumer to wake up blocked producers -#[derive(Debug)] struct SenderTask { task: Option, is_parked: bool, @@ -947,6 +938,18 @@ impl Drop for BoundedSenderInner { } } +impl fmt::Debug for Sender { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Sender").field("closed", &self.is_closed()).finish() + } +} + +impl fmt::Debug for UnboundedSender { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("UnboundedSender").field("closed", &self.is_closed()).finish() + } +} + /* * * ===== impl Receiver ===== @@ -1075,6 +1078,14 @@ impl Stream for Receiver { } } } + + fn size_hint(&self) -> (usize, Option) { + if let Some(inner) = &self.inner { + decode_state(inner.state.load(SeqCst)).size_hint() + } else { + (0, Some(0)) + } + } } impl Drop for Receiver { @@ -1107,6 +1118,18 @@ impl Drop for Receiver { } } +impl fmt::Debug for Receiver { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let closed = if let Some(ref inner) = self.inner { + decode_state(inner.state.load(SeqCst)).is_closed() + } else { + false + }; + + f.debug_struct("Receiver").field("closed", &closed).finish() + } +} + impl UnboundedReceiver { /// Closes the receiving half of a channel, without dropping it. /// @@ -1207,6 +1230,14 @@ impl Stream for UnboundedReceiver { } } } + + fn size_hint(&self) -> (usize, Option) { + if let Some(inner) = &self.inner { + decode_state(inner.state.load(SeqCst)).size_hint() + } else { + (0, Some(0)) + } + } } impl Drop for UnboundedReceiver { @@ -1239,6 +1270,18 @@ impl Drop for UnboundedReceiver { } } +impl fmt::Debug for UnboundedReceiver { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let closed = if let Some(ref inner) = self.inner { + decode_state(inner.state.load(SeqCst)).is_closed() + } else { + false + }; + + f.debug_struct("Receiver").field("closed", &closed).finish() + } +} + /* * * ===== impl Inner ===== @@ -1285,6 +1328,14 @@ impl State { fn is_closed(&self) -> bool { !self.is_open && self.num_messages == 0 } + + fn size_hint(&self) -> (usize, Option) { + if self.is_open { + (self.num_messages, None) + } else { + (self.num_messages, Some(self.num_messages)) + } + } } /* diff --git a/vendor/futures-channel/src/mpsc/queue.rs b/vendor/futures-channel/src/mpsc/queue.rs index 57dc7f565..02ec633fe 100644 --- a/vendor/futures-channel/src/mpsc/queue.rs +++ b/vendor/futures-channel/src/mpsc/queue.rs @@ -61,7 +61,6 @@ pub(super) enum PopResult { Inconsistent, } -#[derive(Debug)] struct Node { next: AtomicPtr, value: Option, @@ -70,7 +69,6 @@ struct Node { /// The multi-producer single-consumer structure. This is not cloneable, but it /// may be safely shared so long as it is guaranteed that there is only one /// popper at a time (many pushers are allowed). -#[derive(Debug)] pub(super) struct Queue { head: AtomicPtr>, tail: UnsafeCell<*mut Node>, diff --git a/vendor/futures-channel/src/oneshot.rs b/vendor/futures-channel/src/oneshot.rs index 5af651b91..70449f43d 100644 --- a/vendor/futures-channel/src/oneshot.rs +++ b/vendor/futures-channel/src/oneshot.rs @@ -390,7 +390,7 @@ impl Drop for Sender { } } -impl fmt::Debug for Sender { +impl fmt::Debug for Sender { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Sender").field("complete", &self.inner.complete).finish() } @@ -481,7 +481,7 @@ impl Drop for Receiver { } } -impl fmt::Debug for Receiver { +impl fmt::Debug for Receiver { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Receiver").field("complete", &self.inner.complete).finish() } -- cgit v1.2.3