Skip to content

Conversation

ADD-SP
Copy link
Member

@ADD-SP ADD-SP commented Aug 31, 2025

Design document

https://gist.github.com/ADD-SP/7558ef3965f18ce1d721dff675d01d9b

Why not deprecate the tokio::io::simplex now?

Since the deprecation is not urgent, we can release this feature and first, and the deprecate the tokio::io::simplex after several months.

issue: #7548

@ADD-SP ADD-SP added C-enhancement Category: A PR with an enhancement or bugfix. A-tokio-util Area: The tokio-util crate M-io Module: tokio/io labels Aug 31, 2025
@ADD-SP ADD-SP force-pushed the add_sp/io-alt-simplex branch 3 times, most recently from ee6ae5a to c8a39fb Compare August 31, 2025 03:45
@ADD-SP ADD-SP force-pushed the add_sp/io-alt-simplex branch from c8a39fb to 43805ab Compare August 31, 2025 04:48
codec = []
time = ["tokio/time", "slab"]
io = []
io = ["tokio/rt"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm. I'd like to avoid this dependence .... could we have Tokio expose no-op methods without rt?

Copy link
Member Author

@ADD-SP ADD-SP Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will open another PR for this change.

I searched the internal usage of coop under the tokio crate, there are many things are heavily using the cfg_coop and poll_proceed_and_make_progress. It is reasonable to expose an no-op method, and also writing a guide for downstream.

cfg_coop! {
fn poll_proceed_and_make_progress(cx: &mut std::task::Context<'_>) -> std::task::Poll<()> {
let coop = std::task::ready!(crate::task::coop::poll_proceed(cx));
coop.made_progress();
std::task::Poll::Ready(())
}
}
cfg_not_coop! {
fn poll_proceed_and_make_progress(_: &mut std::task::Context<'_>) -> std::task::Poll<()> {
std::task::Poll::Ready(())
}
}

Poll::Ready(Ok(()))
} else {
inner.register_receiver_waker(cx.waker());
inner.wake_sender();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to avoid calling wake() under a lock.

Comment on lines +35 to +41
fn with_capacity(backpressure_boundary: usize) -> Self {
Self {
backpressure_boundary,
is_closed: false,
receiver_waker: None,
sender_waker: None,
buf: BytesMut::new(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the method is called with_capacity, then it shoud allocate that much memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tokio-util Area: The tokio-util crate C-enhancement Category: A PR with an enhancement or bugfix. M-io Module: tokio/io

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants