1 // Copyright 2016 Amanieu d'Antras 2 // 3 // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or 4 // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or 5 // http://opensource.org/licenses/MIT>, at your option. This file may not be 6 // copied, modified, or distributed except according to those terms. 7 8 //! This library provides implementations of `Mutex`, `RwLock`, `Condvar` and 9 //! `Once` that are smaller, faster and more flexible than those in the Rust 10 //! standard library. It also provides a `ReentrantMutex` type. 11 12 #![warn(missing_docs)] 13 #![cfg_attr(feature = "nightly", feature(const_fn))] 14 #![cfg_attr(feature = "nightly", feature(integer_atomics))] 15 #![cfg_attr(feature = "nightly", feature(asm))] 16 17 #[cfg(feature = "owning_ref")] 18 extern crate owning_ref; 19 20 #[cfg(not(target_os = "emscripten"))] 21 extern crate thread_id; 22 23 extern crate parking_lot_core; 24 25 #[cfg(not(feature = "nightly"))] 26 mod stable; 27 28 mod util; 29 mod elision; 30 mod raw_mutex; 31 mod raw_remutex; 32 mod raw_rwlock; 33 mod condvar; 34 mod mutex; 35 mod remutex; 36 mod rwlock; 37 mod once; 38 39 pub use once::{Once, ONCE_INIT, OnceState}; 40 pub use mutex::{Mutex, MutexGuard}; 41 pub use remutex::{ReentrantMutex, ReentrantMutexGuard}; 42 pub use condvar::{Condvar, WaitTimeoutResult}; 43 pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; 44 45 #[cfg(feature = "owning_ref")] 46 use owning_ref::OwningRef; 47 48 /// Typedef of an owning reference that uses a `MutexGuard` as the owner. 49 #[cfg(feature = "owning_ref")] 50 pub type MutexGuardRef<'a, T, U = T> = OwningRef<MutexGuard<'a, T>, U>; 51 52 /// Typedef of an owning reference that uses a `ReentrantMutexGuard` as the owner. 53 #[cfg(feature = "owning_ref")] 54 pub type ReentrantMutexGuardRef<'a, T, U = T> = OwningRef<ReentrantMutexGuard<'a, T>, U>; 55 56 /// Typedef of an owning reference that uses a `RwLockReadGuard` as the owner. 57 #[cfg(feature = "owning_ref")] 58 pub type RwLockReadGuardRef<'a, T, U = T> = OwningRef<RwLockReadGuard<'a, T>, U>; 59 60 /// Typedef of an owning reference that uses a `RwLockWriteGuard` as the owner. 61 #[cfg(feature = "owning_ref")] 62 pub type RwLockWriteGuardRef<'a, T, U = T> = OwningRef<RwLockWriteGuard<'a, T>, U>; 63