]> git.lizzy.rs Git - rust.git/commit
Auto merge of #32325 - alexcrichton:panic-once, r=aturon
authorbors <bors@rust-lang.org>
Sat, 26 Mar 2016 22:14:29 +0000 (15:14 -0700)
committerbors <bors@rust-lang.org>
Sat, 26 Mar 2016 22:14:29 +0000 (15:14 -0700)
commit97ec69fb95c9d76dfd051482d827fcf4289c1dbf
tree24be2a03d2d44b6ac5fb705cd0ec6b38ec71c660
parent13bfd5c0b7b57b3e90be5c3e738b8c9426055433
parentc966c330c962f8479882c28a0e430142ef53ee5a
Auto merge of #32325 - alexcrichton:panic-once, r=aturon

std: Rewrite Once with poisoning

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