[−][src]Trait stdext::sync::rw_lock::RwLockExt
Extension trait with useful methods for std::sync::RwLock
.
Required methods
fn force_read(&self) -> RwLockReadGuard<T>
Shorthand for lock.read().unwrap()
with a better panic message.
This method is intended to be used in situations where poisoned locks are considered an exceptional situation and should always result in panic.
Examples
use std::sync::{Arc, RwLock}; use stdext::prelude::*; let lock = Arc::new(RwLock::new(1)); let n = lock.force_read(); assert_eq!(*n, 1);
fn force_write(&self) -> RwLockWriteGuard<T>
Shorthand for lock.write().unwrap()
with a better panic message.
This method is intended to be used in situations where poisoned locks are considered an exceptional situation and should always result in panic.
Examples
use std::sync::{Arc, RwLock}; use stdext::prelude::*; let lock = Arc::new(RwLock::new(1)); { let mut n = lock.force_write(); *n = 2; } let n = lock.force_read(); assert_eq!(*n, 2);