Skip to content

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

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

Closed
joshlf opened this issue Jul 25, 2017 · 1 comment
Closed

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

joshlf opened this issue Jul 25, 2017 · 1 comment
Assignees
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@joshlf
Copy link
Contributor

joshlf commented Jul 25, 2017

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.

@GuillaumeGomez GuillaumeGomez added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Jul 25, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 28, 2017
@frewsxcv frewsxcv self-assigned this Oct 21, 2017
@frewsxcv
Copy link
Member

i opened a pull request for this: #45429

bors added a commit that referenced this issue Oct 22, 2017
Improve docs around `Once::call_once_force` and `OnceState`.

Added some examples, clarify behavior, etc etc.

Fixes #43472.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants