This adds the lazy_static! macro from the lazy_static crate. We need
to re-implement it both since it establishes causality (through its use
of Once), and because the state needs to be cleared on every
execution. This implementation does that.
One unfortunate downside of this implementation is that it is inherently
unsafe. Specifically, in the context of loom, statics are, well, not
static. And yet the API of lazy_static! is such that it gives out
'static references. We cannot safely give out 'static refs into
statics that we clear on every execution.
One option here is to leak every static we allocate. The code would then
be safe (since the references would indeed be 'static), but it would
mean we leak all statics for every execution, no matter whether the
user needs them to be 'static or not.
This adds the
lazy_static!
macro from thelazy_static
crate. We need to re-implement it both since it establishes causality (through its use ofOnce
), and because the state needs to be cleared on every execution. This implementation does that.One unfortunate downside of this implementation is that it is inherently unsafe. Specifically, in the context of loom, statics are, well, not static. And yet the API of
lazy_static!
is such that it gives out'static
references. We cannot safely give out'static
refs into statics that we clear on every execution.One option here is to leak every static we allocate. The code would then be safe (since the references would indeed be
'static
), but it would mean we leak all statics for every execution, no matter whether the user needs them to be'static
or not.Fixes #124.