Skip to content

Commit

Permalink
std: Rewrite Once with poisoning
Browse files Browse the repository at this point in the history
This commit rewrites the `std::sync::Once` primitive with poisoning in mind in
light of #31688. Currently a panic in the initialization closure will cause
future initialization closures to run, but the purpose of a Once is usually to
initialize some global state so it's highly likely that the global state is
corrupt if a panic happened. The same strategy of a mutex is taken where a panic
is propagated by default.

A new API, `call_once_force`, was added to subvert panics like is available on
Mutex as well (for when panicking is handled internally).

Adding this support was a significant enough change to the implementation that
it was just completely rewritten from scratch, primarily to avoid using a
`StaticMutex` which needs to have `destroy()` called on it at some point (a pain
to do).

Closes #31688
  • Loading branch information
alexcrichton committed Mar 26, 2016
1 parent dcfb8d7 commit c966c33
Showing 1 changed file with 363 additions and 56 deletions.
Loading

0 comments on commit c966c33

Please sign in to comment.