Struct widerwlock::WideRwLock
source · pub struct WideRwLock<T: ?Sized> { /* private fields */ }
Expand description
A multi-reader, single writer lock.
The implementation has the following properties:
- Non-reentrant. Do no attempt to take this lock multiple times in the same thread. It will deadlock.
- Writer preferenced: writers will get preference and hold back incoming readers when waiting.
- 8x partitioned: allows very fast multi-reader locking.
- Uncontended single threaded performance better than
std::sync::Mutex
andstd::sync:RwLock
- No poisoning. It should be possible to wrap this lock with poison support if needed.
This struct uses a single pointer to point into a 576 byte (64-byte aligned) heap area
Implementations
sourceimpl<T> WideRwLock<T>
impl<T> WideRwLock<T>
sourcepub fn new(data: T) -> WideRwLock<T>
pub fn new(data: T) -> WideRwLock<T>
creates a new lock
sourceimpl<T: ?Sized> WideRwLock<T>
impl<T: ?Sized> WideRwLock<T>
sourcepub fn read(&self) -> ReadGuard<'_, T>
pub fn read(&self) -> ReadGuard<'_, T>
Obtain a read lock. Multiple simultaneous read locks will be given if there are no writers waiting. The lock remains locked until the returned RAII guard is dropped.
sourcepub fn write(&self) -> WriteGuard<'_, T>
pub fn write(&self) -> WriteGuard<'_, T>
Obtain a write lock. If a writer is waiting, no more read locks will be given until the writer has been granted access and finished. The lock remains locked until the returned RAII guard is dropped.
Trait Implementations
sourceimpl<T: ?Sized> Drop for WideRwLock<T>
impl<T: ?Sized> Drop for WideRwLock<T>
impl<T: ?Sized + Send> Send for WideRwLock<T>
impl<T: ?Sized + Send + Sync> Sync for WideRwLock<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for WideRwLock<T>
impl<T: ?Sized> Unpin for WideRwLock<T>where
T: Unpin,
impl<T: ?Sized> UnwindSafe for WideRwLock<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more