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(const_atomic_u8_new))] 15 #![cfg_attr(feature = "nightly", feature(const_atomic_usize_new))] 16 #![cfg_attr(feature = "nightly", feature(const_cell_new))] 17 #![cfg_attr(feature = "nightly", feature(const_ptr_null_mut))] 18 #![cfg_attr(feature = "nightly", feature(const_atomic_ptr_new))] 19 #![cfg_attr(feature = "nightly", feature(const_unsafe_cell_new))] 20 #![cfg_attr(feature = "nightly", feature(integer_atomics))] 21 #![cfg_attr(feature = "nightly", feature(asm))] 22 23 #[cfg(feature = "owning_ref")] 24 extern crate owning_ref; 25 26 extern crate parking_lot_core; 27 28 #[cfg(not(feature = "nightly"))] 29 mod stable; 30 31 mod util; 32 mod elision; 33 mod raw_mutex; 34 mod raw_remutex; 35 mod raw_rwlock; 36 mod condvar; 37 mod mutex; 38 mod remutex; 39 mod rwlock; 40 mod once; 41 42 #[cfg(feature = "deadlock_detection")] 43 pub mod deadlock; 44 #[cfg(not(feature = "deadlock_detection"))] 45 mod deadlock; 46 47 pub use once::{Once, ONCE_INIT, OnceState}; 48 pub use mutex::{Mutex, MutexGuard}; 49 pub use remutex::{ReentrantMutex, ReentrantMutexGuard}; 50 pub use condvar::{Condvar, WaitTimeoutResult}; 51 pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; 52 53 #[cfg(feature = "owning_ref")] 54 use owning_ref::OwningRef; 55 56 /// Typedef of an owning reference that uses a `MutexGuard` as the owner. 57 #[cfg(feature = "owning_ref")] 58 pub type MutexGuardRef<'a, T, U = T> = OwningRef<MutexGuard<'a, T>, U>; 59 60 /// Typedef of an owning reference that uses a `ReentrantMutexGuard` as the owner. 61 #[cfg(feature = "owning_ref")] 62 pub type ReentrantMutexGuardRef<'a, T, U = T> = OwningRef<ReentrantMutexGuard<'a, T>, U>; 63 64 /// Typedef of an owning reference that uses a `RwLockReadGuard` as the owner. 65 #[cfg(feature = "owning_ref")] 66 pub type RwLockReadGuardRef<'a, T, U = T> = OwningRef<RwLockReadGuard<'a, T>, U>; 67 68 /// Typedef of an owning reference that uses a `RwLockWriteGuard` as the owner. 69 #[cfg(feature = "owning_ref")] 70 pub type RwLockWriteGuardRef<'a, T, U = T> = OwningRef<RwLockWriteGuard<'a, T>, U>; 71