Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.3.26 #2699

Merged
merged 24 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
959e5c5
Do not store items field in ReadyChunks (#2656)
stepancheg Oct 22, 2022
01144e8
Fix clippy::uninlined_format_args warning (#2659)
taiki-e Oct 25, 2022
df2af3a
Do not require Clone for Shared::peek (#2662)
stepancheg Nov 2, 2022
7c30624
Fix miri test failure (#2665)
taiki-e Nov 20, 2022
4f5d770
Ignore clippy::unnecessary_safety_doc lint
taiki-e Nov 27, 2022
a88ea9d
Ignore clippy::let_underscore_future lint
taiki-e Nov 27, 2022
bc39d0d
Custom `Debug` implementations for `mpsc` (#2667)
daxpedda Nov 27, 2022
09a49dc
Remove `Debug` constraint for `oneshot` types (#2666)
daxpedda Nov 27, 2022
64eb689
Stream::size_hint for mpsc channels (#2660)
stepancheg Nov 27, 2022
f67304a
Enable an option for portable-atomic (#2670)
notgull Dec 7, 2022
a69c8d5
Fix build status badge (#2675)
atouchet Dec 17, 2022
90f75e9
impl FusedStream for Buffered (#2676)
arcnmx Dec 19, 2022
c4cd552
improve `try_join_all` and `FuturesUnordered` docs (#2679)
ibraheemdev Jan 1, 2023
2e8178c
Add `ptr_eq` and `ptr_hash` to `Shared` (#2673)
khuey Jan 1, 2023
417435e
Set to `None` only if necessary (#2683)
EFanZh Jan 9, 2023
345c6bb
Update no_atomic_cas.rs
taiki-e Jan 11, 2023
cdb7544
fix panic when Unfold sink return an error (#2686)
erebe Jan 15, 2023
63f2ff2
Remove incorrect error behavior from `ready_chunks` docs (#2687)
jongiddy Jan 15, 2023
e6ea210
Fix bug in FuturesOrdered::push_front (#2664)
conradludgate Jan 15, 2023
c7edb40
Update portable-atomic to 1.0 (#2688)
taiki-e Jan 15, 2023
a2fae9c
Implement `FusedStream` for all streams in `ReadyChunks` (#2693)
jongiddy Jan 20, 2023
35136cf
Add `Either::as_pin_mut` and `Either::as_pin_ref` (#2691)
thomaseizinger Jan 21, 2023
3416c23
Update no_atomic_cas.rs
taiki-e Jan 24, 2023
67f2b54
Release 0.3.26
taiki-e Jan 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 0.3.26 - 2023-01-30

* Add `Either::as_pin_mut` and `Either::as_pin_ref` (#2691)
* Add `Shared::ptr_eq` and `Shared::ptr_hash` (#2691)
* Implement `FusedStream` for `Buffered` (#2676)
* Implement `FusedStream` for all streams in `ReadyChunks` (#2693)
* Fix bug in `FuturesOrdered::push_front` (#2664)
* Remove `Fut::Output: Clone` bounds from some `Shared` methods (#2662)
* Remove `T: Debug` bounds from `Debug` implementations of `mpsc` and `oneshot` types (#2666, #2667)

# 0.3.25 - 2022-10-20

* Fix soundness issue in `join!` and `try_join!` macros (#2649)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

<p align="center">
<a href="https://github.com/rust-lang/futures-rs/actions?query=branch%3Amaster">
<img alt="Build Status" src="https://img.shields.io/github/workflow/status/rust-lang/futures-rs/CI/master">
<img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/rust-lang/futures-rs/ci.yml?branch=master">
</a>

<a href="https://crates.io/crates/futures">
<img alt="Crates.io" src="https://img.shields.io/crates/v/futures.svg">
<img alt="crates.io" src="https://img.shields.io/crates/v/futures.svg">
</a>
</p>

<p align="center">
<a href="https://docs.rs/futures/">
<a href="https://docs.rs/futures">
Documentation
</a> | <a href="https://rust-lang.github.io/futures-rs/">
Website
Expand Down
2 changes: 1 addition & 1 deletion examples/functional/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ fn main() {
// to drive all futures. Eventually fut_values will be driven to completion.
let values: Vec<i32> = executor::block_on(fut_values);

println!("Values={:?}", values);
println!("Values={values:?}");
}
2 changes: 1 addition & 1 deletion examples/imperative/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ fn main() {
// to drive all futures. Eventually fut_values will be driven to completion.
let values: Vec<i32> = executor::block_on(fut_values);

println!("Values={:?}", values);
println!("Values={values:?}");
}
6 changes: 3 additions & 3 deletions futures-channel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "futures-channel"
version = "0.3.25"
version = "0.3.26"
edition = "2018"
rust-version = "1.45"
license = "MIT OR Apache-2.0"
Expand All @@ -22,8 +22,8 @@ unstable = []
cfg-target-has-atomic = []

[dependencies]
futures-core = { path = "../futures-core", version = "0.3.25", default-features = false }
futures-sink = { path = "../futures-sink", version = "0.3.25", default-features = false, optional = true }
futures-core = { path = "../futures-core", version = "0.3.26", default-features = false }
futures-sink = { path = "../futures-sink", version = "0.3.26", default-features = false, optional = true }

[dev-dependencies]
futures = { path = "../futures", default-features = true }
Expand Down
71 changes: 61 additions & 10 deletions futures-channel/src/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,11 @@ mod queue;
#[cfg(feature = "sink")]
mod sink_impl;

#[derive(Debug)]
struct UnboundedSenderInner<T> {
// Channel state shared between the sender and receiver.
inner: Arc<UnboundedInner<T>>,
}

#[derive(Debug)]
struct BoundedSenderInner<T> {
// Channel state shared between the sender and receiver.
inner: Arc<BoundedInner<T>>,
Expand All @@ -122,13 +120,11 @@ impl<T> Unpin for BoundedSenderInner<T> {}
/// The transmission end of a bounded mpsc channel.
///
/// This value is created by the [`channel`](channel) function.
#[derive(Debug)]
pub struct Sender<T>(Option<BoundedSenderInner<T>>);

/// The transmission end of an unbounded mpsc channel.
///
/// This value is created by the [`unbounded`](unbounded) function.
#[derive(Debug)]
pub struct UnboundedSender<T>(Option<UnboundedSenderInner<T>>);

trait AssertKinds: Send + Sync + Clone {}
Expand All @@ -137,15 +133,13 @@ impl AssertKinds for UnboundedSender<u32> {}
/// The receiving end of a bounded mpsc channel.
///
/// This value is created by the [`channel`](channel) function.
#[derive(Debug)]
pub struct Receiver<T> {
inner: Option<Arc<BoundedInner<T>>>,
}

/// The receiving end of an unbounded mpsc channel.
///
/// This value is created by the [`unbounded`](unbounded) function.
#[derive(Debug)]
pub struct UnboundedReceiver<T> {
inner: Option<Arc<UnboundedInner<T>>>,
}
Expand Down Expand Up @@ -261,7 +255,6 @@ impl fmt::Display for TryRecvError {

impl std::error::Error for TryRecvError {}

#[derive(Debug)]
struct UnboundedInner<T> {
// Internal channel state. Consists of the number of messages stored in the
// channel as well as a flag signalling that the channel is closed.
Expand All @@ -277,7 +270,6 @@ struct UnboundedInner<T> {
recv_task: AtomicWaker,
}

#[derive(Debug)]
struct BoundedInner<T> {
// Max buffer size of the channel. If `None` then the channel is unbounded.
buffer: usize,
Expand All @@ -300,7 +292,7 @@ struct BoundedInner<T> {
}

// Struct representation of `Inner::state`.
#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy)]
struct State {
// `true` when the channel is open
is_open: bool,
Expand All @@ -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<Waker>,
is_parked: bool,
Expand Down Expand Up @@ -947,6 +938,18 @@ impl<T> Drop for BoundedSenderInner<T> {
}
}

impl<T> fmt::Debug for Sender<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Sender").field("closed", &self.is_closed()).finish()
}
}

impl<T> fmt::Debug for UnboundedSender<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("UnboundedSender").field("closed", &self.is_closed()).finish()
}
}

/*
*
* ===== impl Receiver =====
Expand Down Expand Up @@ -1075,6 +1078,14 @@ impl<T> Stream for Receiver<T> {
}
}
}

fn size_hint(&self) -> (usize, Option<usize>) {
if let Some(inner) = &self.inner {
decode_state(inner.state.load(SeqCst)).size_hint()
} else {
(0, Some(0))
}
}
}

impl<T> Drop for Receiver<T> {
Expand Down Expand Up @@ -1107,6 +1118,18 @@ impl<T> Drop for Receiver<T> {
}
}

impl<T> fmt::Debug for Receiver<T> {
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<T> UnboundedReceiver<T> {
/// Closes the receiving half of a channel, without dropping it.
///
Expand Down Expand Up @@ -1207,6 +1230,14 @@ impl<T> Stream for UnboundedReceiver<T> {
}
}
}

fn size_hint(&self) -> (usize, Option<usize>) {
if let Some(inner) = &self.inner {
decode_state(inner.state.load(SeqCst)).size_hint()
} else {
(0, Some(0))
}
}
}

impl<T> Drop for UnboundedReceiver<T> {
Expand Down Expand Up @@ -1239,6 +1270,18 @@ impl<T> Drop for UnboundedReceiver<T> {
}
}

impl<T> fmt::Debug for UnboundedReceiver<T> {
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 =====
Expand Down Expand Up @@ -1285,6 +1328,14 @@ impl State {
fn is_closed(&self) -> bool {
!self.is_open && self.num_messages == 0
}

fn size_hint(&self) -> (usize, Option<usize>) {
if self.is_open {
(self.num_messages, None)
} else {
(self.num_messages, Some(self.num_messages))
}
}
}

/*
Expand Down
2 changes: 0 additions & 2 deletions futures-channel/src/mpsc/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pub(super) enum PopResult<T> {
Inconsistent,
}

#[derive(Debug)]
struct Node<T> {
next: AtomicPtr<Self>,
value: Option<T>,
Expand All @@ -70,7 +69,6 @@ struct Node<T> {
/// 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<T> {
head: AtomicPtr<Node<T>>,
tail: UnsafeCell<*mut Node<T>>,
Expand Down
4 changes: 2 additions & 2 deletions futures-channel/src/oneshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<T> Drop for Sender<T> {
}
}

impl<T: fmt::Debug> fmt::Debug for Sender<T> {
impl<T> fmt::Debug for Sender<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Sender").field("complete", &self.inner.complete).finish()
}
Expand Down Expand Up @@ -481,7 +481,7 @@ impl<T> Drop for Receiver<T> {
}
}

impl<T: fmt::Debug> fmt::Debug for Receiver<T> {
impl<T> fmt::Debug for Receiver<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Receiver").field("complete", &self.inner.complete).finish()
}
Expand Down
40 changes: 40 additions & 0 deletions futures-channel/tests/mpsc-size_hint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use futures::channel::mpsc;
use futures::stream::Stream;

#[test]
fn unbounded_size_hint() {
let (tx, mut rx) = mpsc::unbounded::<u32>();
assert_eq!((0, None), rx.size_hint());
tx.unbounded_send(1).unwrap();
assert_eq!((1, None), rx.size_hint());
rx.try_next().unwrap().unwrap();
assert_eq!((0, None), rx.size_hint());
tx.unbounded_send(2).unwrap();
tx.unbounded_send(3).unwrap();
assert_eq!((2, None), rx.size_hint());
drop(tx);
assert_eq!((2, Some(2)), rx.size_hint());
rx.try_next().unwrap().unwrap();
assert_eq!((1, Some(1)), rx.size_hint());
rx.try_next().unwrap().unwrap();
assert_eq!((0, Some(0)), rx.size_hint());
}

#[test]
fn channel_size_hint() {
let (mut tx, mut rx) = mpsc::channel::<u32>(10);
assert_eq!((0, None), rx.size_hint());
tx.try_send(1).unwrap();
assert_eq!((1, None), rx.size_hint());
rx.try_next().unwrap().unwrap();
assert_eq!((0, None), rx.size_hint());
tx.try_send(2).unwrap();
tx.try_send(3).unwrap();
assert_eq!((2, None), rx.size_hint());
drop(tx);
assert_eq!((2, Some(2)), rx.size_hint());
rx.try_next().unwrap().unwrap();
assert_eq!((1, Some(1)), rx.size_hint());
rx.try_next().unwrap().unwrap();
assert_eq!((0, Some(0)), rx.size_hint());
}
3 changes: 2 additions & 1 deletion futures-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "futures-core"
version = "0.3.25"
version = "0.3.26"
edition = "2018"
rust-version = "1.36"
license = "MIT OR Apache-2.0"
Expand All @@ -21,6 +21,7 @@ unstable = []
cfg-target-has-atomic = []

[dependencies]
portable-atomic = { version = "1", default-features = false, optional = true }

[dev-dependencies]
futures = { path = "../futures" }
Expand Down
11 changes: 9 additions & 2 deletions futures-core/src/task/__internal/atomic_waker.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
use core::cell::UnsafeCell;
use core::fmt;
use core::sync::atomic::AtomicUsize;
use core::sync::atomic::Ordering::{AcqRel, Acquire, Release};
use core::task::Waker;

use atomic::AtomicUsize;
use atomic::Ordering::{AcqRel, Acquire, Release};

#[cfg(feature = "portable-atomic")]
use portable_atomic as atomic;

#[cfg(not(feature = "portable-atomic"))]
use core::sync::atomic;

/// A synchronization primitive for task wakeup.
///
/// Sometimes the task interested in a given event will change over time.
Expand Down
8 changes: 4 additions & 4 deletions futures-executor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "futures-executor"
version = "0.3.25"
version = "0.3.26"
edition = "2018"
rust-version = "1.45"
license = "MIT OR Apache-2.0"
Expand All @@ -16,9 +16,9 @@ std = ["futures-core/std", "futures-task/std", "futures-util/std"]
thread-pool = ["std", "num_cpus"]

[dependencies]
futures-core = { path = "../futures-core", version = "0.3.25", default-features = false }
futures-task = { path = "../futures-task", version = "0.3.25", default-features = false }
futures-util = { path = "../futures-util", version = "0.3.25", default-features = false }
futures-core = { path = "../futures-core", version = "0.3.26", default-features = false }
futures-task = { path = "../futures-task", version = "0.3.26", default-features = false }
futures-util = { path = "../futures-util", version = "0.3.26", default-features = false }
num_cpus = { version = "1.8.0", optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion futures-io/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "futures-io"
version = "0.3.25"
version = "0.3.26"
edition = "2018"
rust-version = "1.36"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion futures-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "futures-macro"
version = "0.3.25"
version = "0.3.26"
edition = "2018"
rust-version = "1.45"
license = "MIT OR Apache-2.0"
Expand Down
Loading