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

coop: expose coop as a public module #7116

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

Conversation

maminrayej
Copy link
Member

This PR makes the coop module public and exposes the has_budget_remaining function.

The motivation for this is to make select! budget-aware (see #7108). The exposed functionality is also useful when dealing with a combination of budget-aware and non-budget-aware futures.

Related to #7111.

@maminrayej maminrayej added A-tokio Area: The main tokio crate M-coop Module: tokio/coop labels Jan 21, 2025
@github-actions github-actions bot added R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR R-loom-sync Run loom sync tests on this PR labels Jan 21, 2025
@github-actions github-actions bot removed R-loom-sync Run loom sync tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-current-thread Run loom current-thread tests on this PR labels Jan 21, 2025
@maminrayej maminrayej added the M-runtime Module: tokio/runtime label Jan 21, 2025
tokio/tests/coop_budget.rs Outdated Show resolved Hide resolved
tokio/src/runtime/coop.rs Outdated Show resolved Hide resolved
tokio/src/runtime/coop.rs Show resolved Hide resolved
@github-actions github-actions bot added R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR R-loom-sync Run loom sync tests on this PR labels Jan 22, 2025
tokio/src/io/util/copy.rs Show resolved Hide resolved
tokio/src/task/mod.rs Outdated Show resolved Hide resolved
//! }
//! };
//!
//! task::unconstrained(fut).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are moving this, we should use the new path in examples.

Suggested change
//! task::unconstrained(fut).await;
//! task::coop::unconstrained(fut).await;

//!
//! Documentation for this can be found in the [`tokio::task`] module.
//! See the "Cooperative scheduling" section in the [task](crate::task#cooperative-scheduling) module.
Copy link
Contributor

Choose a reason for hiding this comment

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

You deleted this section.

pub use consume_budget::consume_budget;
pub mod coop;
#[doc(hidden)]
#[deprecated]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[deprecated]
#[deprecated = "Moved to tokio::task::coop::consume_budget"]


#[tokio::test]
async fn test_has_budget_remaining() {
const BUDGET: usize = 128;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's avoid duplicating this constant in every test. Could you move it to the top of this file?

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-runtime Module: tokio/runtime R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR R-loom-sync Run loom sync tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants