diff options
Diffstat (limited to 'tokio-reactor/src/sharded_rwlock.rs')
-rw-r--r-- | tokio-reactor/src/sharded_rwlock.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tokio-reactor/src/sharded_rwlock.rs b/tokio-reactor/src/sharded_rwlock.rs index 6b6207b5..ec16fb13 100644 --- a/tokio-reactor/src/sharded_rwlock.rs +++ b/tokio-reactor/src/sharded_rwlock.rs @@ -4,6 +4,10 @@ //! while making write operations slower. It also incurs much higher memory overhead than //! traditional reader-writer locks. +use crossbeam_utils::CachePadded; +use lazy_static::lazy_static; +use num_cpus; +use parking_lot; use std::cell::UnsafeCell; use std::collections::HashMap; use std::marker::PhantomData; @@ -12,10 +16,6 @@ use std::ops::{Deref, DerefMut}; use std::sync::Mutex; use std::thread::{self, ThreadId}; -use crossbeam_utils::CachePadded; -use num_cpus; -use parking_lot; - /// A scalable read-writer lock. /// /// This type of lock allows a number of readers or at most one writer at any point in time. The @@ -65,7 +65,7 @@ impl<T> RwLock<T> { /// or writers will acquire the lock first. /// /// Returns an RAII guard which will release this thread's shared access once it is dropped. - pub fn read(&self) -> RwLockReadGuard<T> { + pub fn read(&self) -> RwLockReadGuard<'_, T> { // Take the current thread index and map it to a shard index. Thread indices will tend to // distribute shards among threads equally, thus reducing contention due to read-locking. let shard_index = thread_index() & (self.shards.len() - 1); @@ -84,7 +84,7 @@ impl<T> RwLock<T> { /// the lock. /// /// Returns an RAII guard which will drop the write access of this rwlock when dropped. - pub fn write(&self) -> RwLockWriteGuard<T> { + pub fn write(&self) -> RwLockWriteGuard<'_, T> { // Write-lock each shard in succession. for shard in &self.shards { // The write guard is forgotten, but the lock will be manually unlocked in `drop`. @@ -99,7 +99,7 @@ impl<T> RwLock<T> { } /// A guard used to release the shared read access of a `RwLock` when dropped. -pub struct RwLockReadGuard<'a, T: 'a> { +pub struct RwLockReadGuard<'a, T> { parent: &'a RwLock<T>, _guard: parking_lot::RwLockReadGuard<'a, ()>, _marker: PhantomData<parking_lot::RwLockReadGuard<'a, T>>, @@ -116,7 +116,7 @@ impl<'a, T> Deref for RwLockReadGuard<'a, T> { } /// A guard used to release the exclusive write access of a `RwLock` when dropped. -pub struct RwLockWriteGuard<'a, T: 'a> { +pub struct RwLockWriteGuard<'a, T> { parent: &'a RwLock<T>, _marker: PhantomData<parking_lot::RwLockWriteGuard<'a, T>>, } |