Skip to content

Commit 1384a35

Browse files
committed
Merge remote-tracking branch 'upstream/master' into tokio-usdt
2 parents 6700047 + d709df2 commit 1384a35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+576
-175
lines changed

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ R-loom-multi-thread:
1919
- tokio/src/runtime/scheduler/multi_thread/**
2020
- tokio/src/runtime/task/*
2121
- tokio/src/runtime/task/**
22+
23+
R-loom-util:
24+
- tokio-util/src/*
25+
- tokio-util/src/**/*

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818
rust_stable: stable
1919
rust_nightly: nightly-2025-10-12
2020
# Pin a specific miri version
21-
rust_miri_nightly: nightly-2025-06-02
21+
rust_miri_nightly: nightly-2025-11-09
2222
rust_clippy: '1.88'
2323
# When updating this, also update:
2424
# - README.md

.github/workflows/loom.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,19 @@ jobs:
9595
working-directory: tokio
9696
env:
9797
SCOPE: ${{ matrix.scope }}
98+
99+
loom-util:
100+
name: loom tokio-util
101+
# base_ref is null when it's not a pull request
102+
if: github.repository_owner == 'tokio-rs' && (contains(github.event.pull_request.labels.*.name, 'R-loom-util') || (github.base_ref == null))
103+
runs-on: ubuntu-latest
104+
steps:
105+
- uses: actions/checkout@v5
106+
- name: Install Rust ${{ env.rust_stable }}
107+
uses: dtolnay/rust-toolchain@master
108+
with:
109+
toolchain: ${{ env.rust_stable }}
110+
- uses: Swatinem/rust-cache@v2
111+
- name: run tests
112+
run: cargo test --lib --release --features full -- --nocapture
113+
working-directory: tokio-util

tokio-stream/src/stream_ext/chunks_timeout.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ impl<S: Stream> ChunksTimeout<S> {
3333
cap: max_size,
3434
}
3535
}
36+
37+
/// Consumes the [`ChunksTimeout`] and then returns all buffered items.
38+
pub fn into_remainder(mut self: Pin<&mut Self>) -> Vec<S::Item> {
39+
let me = self.as_mut().project();
40+
std::mem::take(me.items)
41+
}
3642
}
3743

3844
impl<S: Stream> Stream for ChunksTimeout<S> {

tokio-stream/src/wrappers.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ cfg_sync! {
2222
}
2323

2424
cfg_signal! {
25-
#[cfg(unix)]
25+
#[cfg(all(unix, not(loom)))]
2626
mod signal_unix;
27-
#[cfg(unix)]
27+
#[cfg(all(unix, not(loom)))]
2828
pub use signal_unix::SignalStream;
2929

3030
#[cfg(any(windows, docsrs))]
@@ -39,12 +39,14 @@ cfg_time! {
3939
}
4040

4141
cfg_net! {
42+
#[cfg(not(loom))]
4243
mod tcp_listener;
44+
#[cfg(not(loom))]
4345
pub use tcp_listener::TcpListenerStream;
4446

45-
#[cfg(unix)]
47+
#[cfg(all(unix, not(loom)))]
4648
mod unix_listener;
47-
#[cfg(unix)]
49+
#[cfg(all(unix, not(loom)))]
4850
pub use unix_listener::UnixListenerStream;
4951
}
5052

@@ -57,6 +59,8 @@ cfg_io_util! {
5759
}
5860

5961
cfg_fs! {
62+
#[cfg(not(loom))]
6063
mod read_dir;
64+
#[cfg(not(loom))]
6165
pub use read_dir::ReadDirStream;
6266
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![warn(rust_2018_idioms)]
2+
3+
use futures::FutureExt;
4+
use std::error::Error;
5+
use tokio::time;
6+
use tokio::time::Duration;
7+
use tokio_stream::{self as stream, StreamExt};
8+
use tokio_test::assert_pending;
9+
use tokio_test::task;
10+
11+
#[tokio::test(start_paused = true)]
12+
async fn stream_chunks_remainder() -> Result<(), Box<dyn Error>> {
13+
let stream1 =
14+
stream::iter([5]).then(move |n| time::sleep(Duration::from_secs(1)).map(move |_| n));
15+
16+
let inner = stream::iter([1, 2, 3, 4]).chain(stream1);
17+
tokio::pin!(inner);
18+
19+
let chunked = (&mut inner).chunks_timeout(10, Duration::from_millis(20));
20+
21+
let mut chunked = task::spawn(chunked);
22+
assert_pending!(chunked.poll_next());
23+
24+
let remainder = chunked.enter(|_, stream| stream.into_remainder());
25+
26+
assert_eq!(remainder, vec![1, 2, 3, 4]);
27+
time::advance(Duration::from_secs(2)).await;
28+
assert_eq!(inner.next().await, Some(5));
29+
Ok(())
30+
}

tokio-util/CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
# 0.7.17 (November 2nd, 2025)
2+
3+
The MSRV is increased to 1.71.
4+
5+
### Added
6+
7+
- codec: add `{FramedRead,FramedWrite}::into_parts()` ([#7566])
8+
- time: add `#[track_caller]` to `FutureExt::timeout` ([#7588])
9+
- task: add `tokio_util::task::JoinQueue` ([#7590])
10+
11+
### Changed
12+
13+
- codec: remove unnecessary trait bounds on all Framed constructors ([#7716])
14+
15+
### Documented
16+
17+
- time: clarify the cancellation safety of the `DelayQueue` ([#7564])
18+
- docs: fix some docs links ([#7654])
19+
- task: simplify the example of `TaskTracker` ([#7657])
20+
- task: clarify the behavior of several `spawn_local` methods ([#7669])
21+
22+
[#7564]: https://github.com/tokio-rs/tokio/pull/7564
23+
[#7566]: https://github.com/tokio-rs/tokio/pull/7566
24+
[#7588]: https://github.com/tokio-rs/tokio/pull/7588
25+
[#7590]: https://github.com/tokio-rs/tokio/pull/7590
26+
[#7654]: https://github.com/tokio-rs/tokio/pull/7654
27+
[#7657]: https://github.com/tokio-rs/tokio/pull/7657
28+
[#7669]: https://github.com/tokio-rs/tokio/pull/7669
29+
[#7716]: https://github.com/tokio-rs/tokio/pull/7716
30+
131
# 0.7.16 (August 3rd, 2025)
232

333
### Added

tokio-util/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "tokio-util"
44
# - Remove path dependencies
55
# - Update CHANGELOG.md.
66
# - Create "tokio-util-0.7.x" git tag.
7-
version = "0.7.16"
7+
version = "0.7.17"
88
edition = "2021"
99
rust-version = "1.71"
1010
authors = ["Tokio Contributors <[email protected]>"]
@@ -57,6 +57,9 @@ futures-test = "0.3.5"
5757
parking_lot = "0.12.0"
5858
tempfile = "3.1.0"
5959

60+
[target.'cfg(loom)'.dev-dependencies]
61+
loom = { version = "0.7", features = ["futures", "checkpoint"] }
62+
6063
[package.metadata.docs.rs]
6164
all-features = true
6265
# enable unstable features in the documentation

tokio-util/src/either.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ where
212212
}
213213
}
214214

215-
#[cfg(test)]
215+
#[cfg(all(test, not(loom)))]
216216
mod tests {
217217
use super::*;
218218
use tokio::io::{repeat, AsyncReadExt, Repeat};

tokio-util/src/loom.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
pub(crate) use std::sync;
1+
//! This module abstracts over `loom` and `std::sync` types depending on whether we
2+
//! are running loom tests or not.
3+
4+
pub(crate) mod sync {
5+
#[cfg(all(test, loom))]
6+
pub(crate) use loom::sync::{Arc, Mutex, MutexGuard};
7+
#[cfg(not(all(test, loom)))]
8+
pub(crate) use std::sync::{Arc, Mutex, MutexGuard};
9+
}

0 commit comments

Comments
 (0)