Skip to content

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

Merged
bors merged 16 commits into
rust-lang:masterfrom
tvallotton:local_waker
Feb 5, 2024
Merged

bors merged 16 commits into
rust-lang:masterfrom
tvallotton:local_waker

Conversation

@tvallotton

Copy link
Copy Markdown
Contributor

Implementation for #118959.

@rustbot

rustbot commented Dec 15, 2023

Copy link
Copy Markdown
Collaborator

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.

@tvallotton tvallotton mentioned this pull request Dec 15, 2023
1 of 4 tasks
@rust-log-analyzer

This comment has been minimized.

Comment thread library/core/src/task/wake.rs
@workingjubilee workingjubilee added the T-libs-api [DEPRECATED; DO NOT USE] label Dec 15, 2023
@tvallotton

Copy link
Copy Markdown
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

rustbot commented Dec 15, 2023

Copy link
Copy Markdown
Collaborator

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

ghost commented Dec 15, 2023 •

Copy link
Copy Markdown
Contributor Author

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

ghost left a comment

Copy link
Copy Markdown
Member

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).

Comment thread library/alloc/src/task.rs Outdated
Comment thread library/alloc/src/task.rs Outdated
Comment thread library/alloc/src/task.rs Outdated
Comment thread library/core/src/task/wake.rs Outdated
Comment thread library/core/src/task/wake.rs Outdated
Comment thread library/core/src/task/wake.rs Outdated
Comment thread library/core/src/task/wake.rs
Comment thread library/core/src/task/wake.rs Outdated
Comment thread library/core/src/task/wake.rs Outdated
Comment thread library/core/src/task/wake.rs Outdated
@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

ghost commented Jan 13, 2024

Copy link
Copy Markdown
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?

ghost left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread library/core/src/task/wake.rs Outdated
@tvallotton

ghost commented Jan 13, 2024

Copy link
Copy Markdown
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

ghost commented Jan 20, 2024

Copy link
Copy Markdown
Collaborator

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

Tomás Vallotton added 2 commits January 20, 2024 10:16
This also removes
* impl From<&Context> for ContextBuilder
* Context::try_waker()

The from implementation is removed because now that
wakers are always supported, there are less incentives
to override the current context. Before, the incentive
was to add Waker support to a reactor that didn't have
any.
@tvallotton

ghost commented Jan 28, 2024

Copy link
Copy Markdown
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

ghost commented Jan 28, 2024

Copy link
Copy Markdown
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

ghost commented Feb 4, 2024

Copy link
Copy Markdown
Member

@bors r+

@bors

ghost commented Feb 4, 2024

Copy link
Copy Markdown
Collaborator

📌 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
@bors
bors merged commit 80e8c7e into rust-lang:master Feb 5, 2024
@rustbot rustbot added this to the 1.78.0 milestone Feb 5, 2024
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 [DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants