Repository navigation
Closed
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.
Milestone
Description
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
- ACP: Add
OnceLock::waitlibs-team#405 - Implementation: std: implement the
once_waitfeature #127567 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Async API (proposed in the ACP): naming, how it works, interaction with other synchronization primitives since e.g.
Mutexdoes not have async methods. This would probably get its own feature gate.
Footnotes
Reacted by Thorsten Sommer, Philip Daniels, Zachary Dremann, alexlapa, José Luis Cruz and orzogc
Reacted by Thorsten Sommer, Kjetil Kjeka, Charles Lew and teor
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.
Activity
Rollup merge of rust-lang#127567 - joboet:once_wait, r=Amanieu
Rollup merge of rust-lang#127567 - joboet:once_wait, r=Amanieu
Unrolled build for rust-lang#127567
PhilipDaniels commentedon Nov 18, 2024
This would be very useful, frankly I was surprised when I ran into the problem of
getbeing non-blocking! Pretty-please can this be moved forward to stabilisation?orlp commentedon Jan 7, 2025
I don't know about
wait_force, but I thinkwaitis clear and uncontroversial enough to stabilize?tgross35 commentedon Jan 7, 2025
wait_forcedoes mirrorcall_once_forceso it makes sense in that regard. That being said, I think the usecases forwait_forceare pretty few and far between outside of implementingOnceLock, and a better solution in the long term will be to use thesync::nonpoisontypes. So, unless there is a convincing usecase (cc author @joboet), maybe it is better to just leavewait_forceinternal? (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::waitandOnceLock::wait, possibly deferringOnce::force_wait.@rustbot label +I-libs-api-nominated
m-ou-se commentedon Jan 14, 2025
@rfcbot merge
rfcbot commentedon 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.
tgross35 commentedon Jan 14, 2025
^ just to clarify what is in FCP, the meeting notes say
rfcbot commentedon Jan 21, 2025
🔔 This is now entering its final comment period, as per the review above. 🔔
rfcbot commentedon Jan 31, 2025
The final comment period, with a disposition to merge, as per the review above, is now complete.
As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.
This will be merged soon.
Rollup merge of rust-lang#136360 - slanterns:once_wait, r=tgross35
Unrolled build for rust-lang#136360
Rollup merge of rust-lang#136360 - slanterns:once_wait, r=tgross35