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

Tracking Issue for once_wait #127527

Open
2 of 4 tasks
tgross35 opened this issue Jul 9, 2024 · 7 comments
Open
2 of 4 tasks

Tracking Issue for once_wait #127527

tgross35 opened this issue Jul 9, 2024 · 7 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@tgross35
Copy link
Contributor

tgross35 commented Jul 9, 2024

Feature gate: #![feature(once_wait)]

This is a tracking issue for adding a blocking .wait() method on Once and OnceLock, to allow other threads to synchronize on their completion. This will provide the same interface as once_cell's OnceCell::wait.

Public API

impl Once {
    /// Block the current thread until the `Once` has been initialized.
    fn wait(&self);
    /// Block the current thread until the `Once` has been initialized, ignoring poisoning.
    fn wait_force(&self);
}

impl OnceLock {
    /// Block the current thread until the value is set, then return it.
    fn wait(&self) -> &T;
}

Steps / History

Unresolved Questions

  • Async API (proposed in the ACP): naming, how it works, interaction with other synchronization primitives since e.g. Mutex does not have async methods. This would probably get its own feature gate.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@tgross35 tgross35 added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jul 9, 2024
tgross35 added a commit to tgross35/rust that referenced this issue Jul 31, 2024
std: implement the `once_wait` feature

Tracking issue: rust-lang#127527

This additionally adds a `wait_force` method to `Once` that doesn't panic on poison.

I also took the opportunity and cleaned up up the code of the queue-based implementation a bit.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 31, 2024
std: implement the `once_wait` feature

Tracking issue: rust-lang#127527

This additionally adds a `wait_force` method to `Once` that doesn't panic on poison.

I also took the opportunity and cleaned up up the code of the queue-based implementation a bit.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 1, 2024
Rollup merge of rust-lang#127567 - joboet:once_wait, r=Amanieu

std: implement the `once_wait` feature

Tracking issue: rust-lang#127527

This additionally adds a `wait_force` method to `Once` that doesn't panic on poison.

I also took the opportunity and cleaned up up the code of the queue-based implementation a bit.
@PhilipDaniels
Copy link
Contributor

This would be very useful, frankly I was surprised when I ran into the problem of get being non-blocking! Pretty-please can this be moved forward to stabilisation?

@orlp
Copy link
Contributor

orlp commented Jan 7, 2025

I don't know about wait_force, but I think wait is clear and uncontroversial enough to stabilize?

@tgross35
Copy link
Contributor Author

tgross35 commented Jan 7, 2025

wait_force does mirror call_once_force so it makes sense in that regard. That being said, I think the usecases for wait_force are pretty few and far between outside of implementing OnceLock, and a better solution in the long term will be to use the sync::nonpoison types. So, unless there is a convincing usecase (cc author @joboet), maybe it is better to just leave wait_force internal? (quick usage search doesn't show anything, not entirely surprising for less common nightly API though).

Requesting libs-api to consider stabilizing at least Once::wait and OnceLock::wait, possibly deferring Once::force_wait.

@rustbot label +I-libs-api-nominated

@rustbot rustbot added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Jan 7, 2025
@m-ou-se
Copy link
Member

m-ou-se commented Jan 14, 2025

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Jan 14, 2025

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jan 14, 2025
@tgross35
Copy link
Contributor Author

tgross35 commented Jan 14, 2025

^ just to clarify what is in FCP, the meeting notes say

No reason to not also include wait_force

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Jan 21, 2025
@rfcbot
Copy link

rfcbot commented Jan 21, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@dtolnay dtolnay removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants