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 task::Waker::noop #96875

Merged
merged 2 commits into from
Jun 7, 2023
Merged

Add task::Waker::noop #96875

merged 2 commits into from
Jun 7, 2023

Conversation

SabrinaJewson
Copy link
Contributor

@SabrinaJewson SabrinaJewson commented May 9, 2022

I have found myself reimplementing this function many times when I need a Context but don't have a runtime or futures to hand.

Prior art: futures::task::noop_waker and futures::task::noop_waker_ref

Tracking issue: #98286

Unresolved questions:

  1. Should we also add RawWaker::noop()? (I don't think so, I can't think of a use case for it)
  2. Should we also add Context::noop()? Depending on the future direction Context goes a "noop context" might not even make sense in future.
  3. Should it be an associated constant instead? That would allow for let cx = &mut Context::from_waker(&Waker::NOOP); to work on one line which is pretty nice. I don't really know what the guideline is here.

r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs

@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added 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. labels May 9, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 9, 2022
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2022
@JohnTitor
Copy link
Member

Could you open a new tracking issue? https://togithub.com/rust-lang/rust/issues/98262 is a good example.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 24, 2022
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2022
@pitaj pitaj added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2023
@pitaj
Copy link
Contributor

pitaj commented May 5, 2023

@m-ou-se ping from triage, no movement for 11 months. What is the status of this PR?

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 3, 2023
@m-ou-se
Copy link
Member

m-ou-se commented Jun 6, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Jun 6, 2023

📌 Commit 1818ed7 has been approved by m-ou-se

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-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Jun 6, 2023
#[must_use]
#[unstable(feature = "noop_waker", issue = "98286")]
pub const fn noop() -> Waker {
const VTABLE: RawWakerVTable = RawWakerVTable::new(
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make this a static such that the vtable is shared between all times RawWaker is codegened?

@bors
Copy link
Contributor

bors commented Jun 7, 2023

⌛ Testing commit 1818ed7 with merge 10b7e46...

@bors
Copy link
Contributor

bors commented Jun 7, 2023

☀️ Test successful - checks-actions
Approved by: m-ou-se
Pushing 10b7e46 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 7, 2023
@bors bors merged commit 10b7e46 into rust-lang:master Jun 7, 2023
1 check passed
@rustbot rustbot added this to the 1.72.0 milestone Jun 7, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (10b7e46): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.6% [-4.8%, -4.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.6% [-4.8%, -4.4%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.3% [1.3%, 1.3%] 1
Regressions ❌
(secondary)
2.5% [2.5%, 2.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.8% [-3.8%, -3.8%] 1
All ❌✅ (primary) 1.3% [1.3%, 1.3%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 647.662s -> 647.017s (-0.10%)

@SabrinaJewson SabrinaJewson deleted the noop-waker branch August 1, 2023 15:07
@traviscross traviscross added the WG-async Working group: Async & await label Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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. WG-async Working group: Async & await
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet