replace synchronization primitives with those from parking_lot (#1593)
* parking_lot in cargo.toml * replace all lock invocations with parking_lot ones * use parking_lot synchronization primitives
This commit is contained in:
committed by
Gav Wood
parent
4226c0f631
commit
36d3d0d7d7
@@ -64,29 +64,4 @@ pub fn version_data() -> Bytes {
|
||||
s.append(&rustc_version());
|
||||
s.append(&&Target::os()[0..2]);
|
||||
s.out()
|
||||
}
|
||||
|
||||
/// Object can be locked directly into a `MutexGuard`.
|
||||
pub trait Lockable<T> {
|
||||
/// Lock object directly into a `MutexGuard`.
|
||||
fn locked(&self) -> MutexGuard<T>;
|
||||
}
|
||||
|
||||
impl<T> Lockable<T> for Mutex<T> {
|
||||
fn locked(&self) -> MutexGuard<T> { self.lock().unwrap() }
|
||||
}
|
||||
|
||||
/// Object can be read or write locked directly into a guard.
|
||||
pub trait RwLockable<T> {
|
||||
/// Read-lock object directly into a `ReadGuard`.
|
||||
fn unwrapped_read(&self) -> RwLockReadGuard<T>;
|
||||
|
||||
/// Write-lock object directly into a `WriteGuard`.
|
||||
fn unwrapped_write(&self) -> RwLockWriteGuard<T>;
|
||||
}
|
||||
|
||||
impl<T> RwLockable<T> for RwLock<T> {
|
||||
fn unwrapped_read(&self) -> RwLockReadGuard<T> { self.read().unwrap() }
|
||||
fn unwrapped_write(&self) -> RwLockWriteGuard<T> { self.write().unwrap() }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user