1 unstable release
0.1.0 | Dec 10, 2019 |
---|
#1153 in Concurrency
115KB
2.5K
SLoC
static_locks
The parking_lot
locks but modified
so that they can be used in statics on stable Rust.
The only thing preventing this was the fact that the API was implemented in a
generic way in lock_api
, and const trait bounds aren't fully supported yet.
All this crate does is manually monomorphize (expand) the generic
implementation, allowing Mutex::new
, RwLock::new
, and ReentrantMutex::new
,
etc to be used in statics.
It essentially exists so that you don't have to use a lazy_static or OnceCell for in cases where you shouldn't.
Caveats
- Can't use our
MutexGuard
withCondvar
from normalparking_lot
. - Some features have been renamed, e.g. serde => serde_support, in order to meet cargos rule about not having a feature && dep of the same name.
- Doesn't contain things from parking_lot other than the locks, although we do
reexport the parking lot crate, e.g.
static_locks::parking_lot::{...}
is available.
License
Same as parking_lot
, down to the copyright attribution. The author of
stable_locks
claims no additional copyright over the changes to the
parking_lot code needed -- They were trivial.
Dependencies
~0.5–6MB
~32K SLoC