Skip to content

std::sync::OnceState: Confusing documentation for poisoned method #43472

Closed
@joshlf

Description

@joshlf

The documentation for std::sync::OnceState::poisoned reads:

Returns whether the associated Once has been poisoned.

Once an initalization routine for a Once has panicked it will forever indicate to future forced initialization routines that it is poisoned.

This is confusing because it implies that calls to call_once_force can execute multiple times, but of course the whole point of a Once is that calls only execute once. Even call_once_force only executes so long as the Once is poisoned - as soon as it is in the COMPLETE state, call_once_force calls become no-ops.

A better wording might be:

Once an initialization routine for a Once has panicked, it will forever indicate to future forced initialization routines that it is poisoned. Of course, once a single forced initialization routine successfully completes, the Once will no longer be poisoned, but no future initialization routes will be run either.

Metadata

Metadata

Assignees

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions