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 · 1 comment
Open
2 of 4 tasks

Tracking Issue for once_wait #127527

tgross35 opened this issue Jul 9, 2024 · 1 comment
Labels
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.

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?

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

2 participants