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.
Feature gate:
#![feature(once_wait)]This is a tracking issue for adding a blocking
.wait()method onOnceandOnceLock, to allow other threads to synchronize on their completion. This will provide the same interface asonce_cell'sOnceCell::wait.Public API
Steps / History
OnceLock::waitlibs-team#405once_waitfeature #127567Unresolved Questions
Mutexdoes not have async methods. This would probably get its own feature gate.Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩