pub struct BarrierRwLock<T: ?Sized> { /* private fields */ }Expand description
A read/write lock using VPP’s barrier to provide exclusion between threads
VPP implements a barrier in the main thread which blocks all worker threads from running. The
BarrierRwLock is an abstraction around this which allows a writer in the VPP main thread
whilst the barrier is held and readers in either VPP workers or the VPP main thread.
Taking read or write “locks” are guaranteed to never block - blocking instead occurs in the VPP main and worker threads when the VPP barrier is taken.
Implementations§
Source§impl<T> BarrierRwLock<T>
impl<T> BarrierRwLock<T>
Source§impl<T: ?Sized> BarrierRwLock<T>
impl<T: ?Sized> BarrierRwLock<T>
Sourcepub fn read(&self, vm: &MainRef) -> BarrierRwLockReadGuard<'_, T>
pub fn read(&self, vm: &MainRef) -> BarrierRwLockReadGuard<'_, T>
Locks this BarrierRwLock with shared read access.
Returns an RAII guard which will release this thread’s shared access once it is dropped.
§Panics
Panics if a write lock has already been taken by this thread and not dropped.
Sourcepub fn write(&self, vm: &BarrierHeldMainRef) -> BarrierRwLockWriteGuard<'_, T>
pub fn write(&self, vm: &BarrierHeldMainRef) -> BarrierRwLockWriteGuard<'_, T>
Locks this BarrierRwLock with write access.
This is used on the VPP main thread in contexts where the VPP barrier is held.
Returns an RAII guard which will release this thread’s access once it is dropped.
§Panics
Panics if a read or another write lock has already been taken by this thread and not dropped.
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Get a mutable reference to the contained data without locking.
This call borrows the BarrierRwLock mutably (at compile-time) which guarantees that we
possess the only reference.
Sourcepub const fn data_ptr(&self) -> *mut T
pub const fn data_ptr(&self) -> *mut T
Returns a raw pointer to the underlying data.
The returned pointer is always non-null and properly aligned, but it is the user’s responsibility to ensure that any reads and writes through it are properly synchronized to avoid data races, and that it is not read or written through after the lock is dropped.
Source§impl<T> BarrierRwLock<T>
impl<T> BarrierRwLock<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the lock and return the underlying data.
Trait Implementations§
Source§impl<T: Default> Default for BarrierRwLock<T>
impl<T: Default> Default for BarrierRwLock<T>
Source§fn default() -> BarrierRwLock<T>
fn default() -> BarrierRwLock<T>
Creates a new BarrierRwLock<T>, with the Default value for T.