This gets rid of the dangerous static mut, adds more comments about the code, relaxes the orderings and documents the unsoundness of the clear function.
It implements a small once_cell-like abstraction.
I also noticed that the whole #[cfg(atomic_cas)] seems pretty pointless since this crate doesn't support no_std anyways.
About clear_recorder: This function was unsound before as well, since the following interleaving was possible:
Thread A reads the state as init
Thread B clears
Thread B CASes the state and starts writing to the recorder
This gets rid of the dangerous
static mut
, adds more comments about the code, relaxes the orderings and documents the unsoundness of theclear
function.It implements a small once_cell-like abstraction.
I also noticed that the whole
#[cfg(atomic_cas)]
seems pretty pointless since this crate doesn't supportno_std
anyways.About
clear_recorder
: This function was unsound before as well, since the following interleaving was possible: