Skip to content

Make cooperative and poll_proceed public #7405

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

Merged
merged 14 commits into from
Jul 11, 2025
Merged

Conversation

pepijnve
Copy link
Contributor

@pepijnve pepijnve commented Jun 12, 2025

Motivation

In systems that use the Tokio runtime, it can be useful to integrate non-Tokio resources with the Tokio task budget. This makes it easier to ensure all tasks yield sufficiently. Currently only consume_budget is available, but this is impractical when trying to make certain types like Future or Stream participate in cooperative scheduling.

Closes #7403

Solution

Make the existing cooperative and poll_proceed methods public.
Clarify the documentation of poll_proceed.

@pepijnve pepijnve force-pushed the issue_7403 branch 5 times, most recently from 79e9505 to ab9db65 Compare June 13, 2025 06:36
@pepijnve pepijnve force-pushed the issue_7403 branch 2 times, most recently from a21ed1b to 4ad718d Compare June 13, 2025 07:36
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-coop Module: tokio/coop labels Jun 13, 2025
@pepijnve
Copy link
Contributor Author

@Darksonn let me know if there's anything else I can do to help move this one along. In the meantime in DataFusion I've approximated poll_proceed/made_progress using has_budget_remaining/consume_budget. That's not exactly the same, but a good enough approximation for now. Would be nice to be able to remove that code with the next Tokio release.

@pepijnve
Copy link
Contributor Author

@Darksonn comments addressed, only a bit unsure about unwind safety.

@pepijnve
Copy link
Contributor Author

pepijnve commented Jul 9, 2025

@Darksonn I understand if this one is pretty low on the priorities list. Just wanted to say that from my point of view this is as complete as I can get it. Happy to continue working on it if anything specific still needs to be done.

@Darksonn
Copy link
Contributor

Darksonn commented Jul 9, 2025

Overall LGTM.

@pepijnve
Copy link
Contributor Author

pepijnve commented Jul 10, 2025

Overall LGTM.

Latest round of comments processed.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thanks.

@Darksonn Darksonn enabled auto-merge (squash) July 11, 2025 07:50
@pepijnve
Copy link
Contributor Author

Thanks.

Terse. 😄

Thanks for the taking the time to review thoroughly and helping me stumble through the learning process.

@Darksonn
Copy link
Contributor

I'm happy to have you :)

@Darksonn Darksonn merged commit 611b793 into tokio-rs:master Jul 11, 2025
86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-coop Module: tokio/coop
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Capability to make an existing Stream participate in cooperative scheduling
2 participants