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

Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc. #118960

Merged
merged 16 commits into from
Feb 5, 2024

Conversation

tvallotton
Copy link
Contributor

Implementation for #118959.

@rustbot
Copy link
Collaborator

rustbot commented Dec 15, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 15, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@workingjubilee workingjubilee added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Dec 15, 2023
@tvallotton
Copy link
Contributor Author

This CI failure is strange:

Error: tidy error: /checkout/library/core/src/task/wake.rs:713: issue "87021" mismatches the previous issue of "96992"

It seems the error message is correct about the fact that we shouldn't be linking to #87021 and we should link instead to #96992. But it makes me question why does it only fail on my branch, I didn't change this issue number after all.

@rustbot
Copy link
Collaborator

rustbot commented Dec 15, 2023

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

@tvallotton
Copy link
Contributor Author

tvallotton commented Dec 15, 2023

Just for the record, it might be wise to check if ContextBuilder<'a> should be future proofed to be invariant, since I noticed that the with_waker example seems to break when changing the variance. Naturally, that makes the implementation of From<&mut Context> practically useless.

EDIT: This implementation was later removed

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

Do we have signoff from T-libs-api on the new unstable surface area? The ACP issue seems to have had a good bit of discussion but I didn't see that signoff made explicit. If you can drive that towards a comment here or there and/or link something, that would be good.

I'm particularly concerned about the surface area confusing newer users -- especially given the frequent concerns over async complexity -- I wonder if we should add a sentence/paragraph to the top-level docs in https://doc.rust-lang.org/nightly/std/task/index.html to clarify the current state (i.e., stable surface area should be sufficient for most uses or so).

library/alloc/src/task.rs Outdated Show resolved Hide resolved
library/alloc/src/task.rs Outdated Show resolved Hide resolved
library/alloc/src/task.rs Outdated Show resolved Hide resolved
library/core/src/task/wake.rs Outdated Show resolved Hide resolved
library/core/src/task/wake.rs Outdated Show resolved Hide resolved
library/core/src/task/wake.rs Outdated Show resolved Hide resolved
library/core/src/task/wake.rs Show resolved Hide resolved
library/core/src/task/wake.rs Outdated Show resolved Hide resolved
library/core/src/task/wake.rs Outdated Show resolved Hide resolved
library/core/src/task/wake.rs Outdated Show resolved Hide resolved
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 31, 2023
@tvallotton
Copy link
Contributor Author

I wonder if we should add a sentence/paragraph to the top-level docs in https://doc.rust-lang.org/nightly/std/task/index.html to clarify the current state (i.e., stable surface area should be sufficient for most uses or so).

I think it may be better to put it on the docs for LocalWaker. What do you think?

Copy link
Contributor

@Thomasdezeeuw Thomasdezeeuw left a comment

Choose a reason for hiding this comment

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

I like to see a LocalWaker type, but this not the way to do it in my opinion. That's coming from someone who has written a lot of Futures, async function and a runtime specialised in thread-locality (i.e. I very much like to see this change).

I don't think making the Waker optional in Context is wise considering all existing Future related code depends on the Waker type always being part of the Context, it was never not there, a promise we're walking back with this pr.

library/core/src/task/wake.rs Outdated Show resolved Hide resolved
@tvallotton
Copy link
Contributor Author

I made the waker type mandatory on the last commit. Several people have expressed their concern with this aspect of the API. And while I do think that it is better for them to be optional than not, that is not something I consider terribly important.

@bors
Copy link
Contributor

bors commented Jan 20, 2024

☔ The latest upstream changes (presumably #120136) made this pull request unmergeable. Please resolve the merge conflicts.

@tvallotton
Copy link
Contributor Author

@Mark-Simulacrum Do we really need an explicit signoff here? Both teams have discussed it and approved nightly experimentation (libs-team, wg-async). I feel that with no significant changes on the proposal, it is going to be hard to get the teams to meet to discuss the same topic again.

@Mark-Simulacrum
Copy link
Member

Those comments seem sufficient to me (I hadn't seen them in my quick skim) for nightly experimentation.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 28, 2024
@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 4, 2024

📌 Commit 180c68b has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 4, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 5, 2024
…ulacrum

Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.

Implementation for  rust-lang#118959.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 5, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#113833 (`std::error::Error` -> Trait Implementations: lifetimes consistency improvement)
 - rust-lang#115386 (PartialEq, PartialOrd: update and synchronize handling of transitive chains)
 - rust-lang#116284 (make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern)
 - rust-lang#118960 (Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.)
 - rust-lang#120060 (Use the same mir-opt bless targets on all platforms)
 - rust-lang#120214 (match lowering: consistently lower bindings deepest-first)
 - rust-lang#120384 (Use `<T, U>` for array/slice equality `impl`s)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 5, 2024
…ulacrum

Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.

Implementation for  rust-lang#118959.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 5, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#113833 (`std::error::Error` -> Trait Implementations: lifetimes consistency improvement)
 - rust-lang#115386 (PartialEq, PartialOrd: update and synchronize handling of transitive chains)
 - rust-lang#116284 (make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern)
 - rust-lang#118960 (Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.)
 - rust-lang#120384 (Use `<T, U>` for array/slice equality `impl`s)
 - rust-lang#120518 (riscv only supports split_debuginfo=off for now)
 - rust-lang#120619 (Assert that params with the same *index* have the same *name*)
 - rust-lang#120657 (Remove unused struct)
 - rust-lang#120661 (target: default to the medium code model on LoongArch targets)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 5, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#113833 (`std::error::Error` -> Trait Implementations: lifetimes consistency improvement)
 - rust-lang#115386 (PartialEq, PartialOrd: update and synchronize handling of transitive chains)
 - rust-lang#116284 (make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern)
 - rust-lang#118960 (Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.)
 - rust-lang#120384 (Use `<T, U>` for array/slice equality `impl`s)
 - rust-lang#120518 (riscv only supports split_debuginfo=off for now)
 - rust-lang#120657 (Remove unused struct)
 - rust-lang#120661 (target: default to the medium code model on LoongArch targets)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 5, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#113833 (`std::error::Error` -> Trait Implementations: lifetimes consistency improvement)
 - rust-lang#115386 (PartialEq, PartialOrd: update and synchronize handling of transitive chains)
 - rust-lang#116284 (make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern)
 - rust-lang#118960 (Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.)
 - rust-lang#120384 (Use `<T, U>` for array/slice equality `impl`s)
 - rust-lang#120518 (riscv only supports split_debuginfo=off for now)
 - rust-lang#120657 (Remove unused struct)
 - rust-lang#120661 (target: default to the medium code model on LoongArch targets)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 80e8c7e into rust-lang:master Feb 5, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 5, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 5, 2024
Rollup merge of rust-lang#118960 - tvallotton:local_waker, r=Mark-Simulacrum

Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.

Implementation for  rust-lang#118959.
bors added a commit to rust-lang/rust-analyzer that referenced this pull request Feb 8, 2024
fix: waker_getters tracking issue from 87021 for 96992.

I was directed to make the fix here by this comment rust-lang/rust#118960 (comment).
bors pushed a commit to rust-lang-ci/rust that referenced this pull request Feb 18, 2024
…ulacrum

Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.

Implementation for  rust-lang#118959.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 11, 2024
…cuviper

make LocalWaker::will_wake consistent with Waker::will_wake

This mirrors rust-lang#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang#118960).
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 11, 2024
…cuviper

make LocalWaker::will_wake consistent with Waker::will_wake

This mirrors rust-lang#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang#118960).
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 11, 2024
Rollup merge of rust-lang#128882 - RalfJung:local-waker-will-wake, r=cuviper

make LocalWaker::will_wake consistent with Waker::will_wake

This mirrors rust-lang#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang#118960).
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Aug 12, 2024
make LocalWaker::will_wake consistent with Waker::will_wake

This mirrors rust-lang/rust#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang/rust#118960).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants