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 #![warn(rust_2018_idioms)] 14 15 mod condvar; 16 mod elision; 17 mod fair_mutex; 18 mod mutex; 19 mod once; 20 mod raw_fair_mutex; 21 mod raw_mutex; 22 mod raw_rwlock; 23 mod remutex; 24 mod rwlock; 25 mod util; 26 27 #[cfg(feature = "deadlock_detection")] 28 pub mod deadlock; 29 #[cfg(not(feature = "deadlock_detection"))] 30 mod deadlock; 31 32 // If deadlock detection is enabled, we cannot allow lock guards to be sent to 33 // other threads. 34 #[cfg(all(feature = "send_guard", feature = "deadlock_detection"))] 35 compile_error!("the `send_guard` and `deadlock_detection` features cannot be used together"); 36 #[cfg(feature = "send_guard")] 37 type GuardMarker = lock_api::GuardSend; 38 #[cfg(not(feature = "send_guard"))] 39 type GuardMarker = lock_api::GuardNoSend; 40 41 pub use self::condvar::{Condvar, WaitTimeoutResult}; 42 pub use self::fair_mutex::{const_fair_mutex, FairMutex, FairMutexGuard, MappedFairMutexGuard}; 43 pub use self::mutex::{const_mutex, MappedMutexGuard, Mutex, MutexGuard}; 44 pub use self::once::{Once, OnceState}; 45 pub use self::raw_fair_mutex::RawFairMutex; 46 pub use self::raw_mutex::RawMutex; 47 pub use self::raw_rwlock::RawRwLock; 48 pub use self::remutex::{ 49 const_reentrant_mutex, MappedReentrantMutexGuard, RawThreadId, ReentrantMutex, 50 ReentrantMutexGuard, 51 }; 52 pub use self::rwlock::{ 53 const_rwlock, MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, 54 RwLockUpgradableReadGuard, RwLockWriteGuard, 55 }; 56 pub use ::lock_api; 57