Skip to content

Tracking Issue for once_wait #127527

Closed
@tgross35

Description

@tgross35

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.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.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions