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
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
@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(())
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I found an alternative to avoid this dependency.

cfg_rt! {
use std::task::{Context, Poll};
use tokio::task::coop::poll_proceed;
use futures_core::ready;
#[cfg_attr(not(feature = "io"), allow(unused))]
pub(crate) fn poll_proceed_and_make_progress(cx: &mut Context<'_>) -> Poll<()> {
ready!(poll_proceed(cx)).made_progress();
Poll::Ready(())
}
}
cfg_not_rt! {
use std::task::{Context, Poll};
#[cfg_attr(not(feature = "io"), allow(unused))]
pub(crate) fn poll_proceed_and_make_progress(_cx: &mut Context<'_>) -> Poll<()> {
Poll::Ready(())
}
}

Copy link
Member Author

@ADD-SP ADD-SP Nov 5, 2025

Choose a reason for hiding this comment

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

could we have Tokio expose no-op methods without rt?

There’s a small problem if we expose a no-op method without rt. The behavior of tokio::task::coop::* would become a bit surprising, and we’d need to write more documentation to explain it.

Fortunately, I found the alternative above, so we don’t need to worry about this issue.

Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
@ADD-SP ADD-SP requested review from Darksonn and martin-g November 5, 2025 12:26
@martin-g
Copy link
Member

martin-g commented Nov 5, 2025

Both the issue and the implementation (this PR) do not say anything about vectored writes (https://docs.rs/tokio/1.48.0/src/tokio/io/util/mem.rs.html#387-400)
Are they omitted intentionally ?

1. The `Sender` should not hang forever when the input buf is empty
2. The `Receiver` should not hange forever when the input buf is full

Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
@ADD-SP ADD-SP requested a review from martin-g November 5, 2025 15:25
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
@github-actions github-actions bot added the R-loom-util Run loom tokio-util tests on this PR label Nov 6, 2025
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
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 R-loom-util Run loom tokio-util tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants