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

macros: make select budget-aware #7111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maminrayej
Copy link
Member

This PR introduces a new function called poll_budget_available which can be called in order to poll for budget availability. This is then used in select!, before polling the branches, in order to make select budget-aware.

Resolves #7108.

@maminrayej maminrayej added A-tokio Area: The main tokio crate M-task Module: tokio/task M-macros Module: macros in the main Tokio crate labels Jan 18, 2025
@maminrayej maminrayej force-pushed the feat/budget-aware-select branch from ec44313 to 762526e Compare January 18, 2025 20:06
@Darksonn Darksonn added the M-coop Module: tokio/coop label Jan 20, 2025
Comment on lines +50 to +59
#[cfg_attr(docsrs, doc(cfg(feature = "rt")))]
pub fn poll_budget_available(cx: &mut Context<'_>) -> Poll<()> {
ready!(crate::trace::trace_leaf(cx));
if crate::runtime::coop::has_budget_remaining() {
Poll::Ready(())
} else {
cx.waker().wake_by_ref();
Poll::Pending
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the poll_proceed / made_progress API we use internally is good. If we're going to expose more of coop, then I think we should expose that API instead of inventing a new one.

But I wouldn't do both "expose coop API" and "make select coop aware" in one PR. I'd like two PRs for the changelog.

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 M-macros Module: macros in the main Tokio crate M-task Module: tokio/task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MPSC queue hangs on repeated polling
2 participants