Struct ruspiro_lock::sync::RWLock[][src]

#[repr(C, align(16))]
pub struct RWLock<T: ?Sized> { /* fields omitted */ }

An exclusive access lock around the given data

Implementations

impl<T> RWLock<T>[src]

pub const fn new(value: T) -> Self[src]

Create a new data access guarding lock.

pub fn try_lock(&self) -> Option<WriteLockGuard<'_, T>>[src]

Try to lock the guarded data for mutual exclusive access. Returns None if the lock fails or Some(WriteLockGuard). The actual data, the WriteLockGuard wraps could be conviniently accessed by dereferencing it.

pub fn lock(&self) -> WriteLockGuard<'_, T>[src]

Lock the guarded data for mutual exclusive access. This blocks until the data could be successfully locked. This also implies that there is no concurrent ReadLockGuard existing. The locked data will be returned as WriteLockGuard. Simply derefrencing this allows access to the contained data value.

pub fn try_read(&self) -> Option<ReadLockGuard<'_, T>>[src]

Provide a ReadLock to the wrapped data. This call blocks until the recource is available. There can be as many concurrent ReadLockGuards being handed out if there is no WriteLockGuard to the same resource already existing.

pub fn read(&self) -> ReadLockGuard<'_, T>[src]

Provide a ReadLock to the wrapped data. This call blocks until the recource is available. There can be as many concurrent ReadLockGuards being handed out if there is no WriteLockGuard to the same resource already existing.

pub unsafe fn as_ref_unchecked(&self) -> &T[src]

Provide an immutable borrow to the data secured by the RWLock.

Safety

This is only safe if it is guarantied that there is exactly only one call to this function or any other accessor of the RWLock until the returned borrow goes out of scope.

pub fn into_inner(self) -> T where
    T: Sized
[src]

Consume the Mutex and return the inner value

Trait Implementations

impl<T> Debug for RWLock<T> where
    T: Debug
[src]

impl<T> Sync for RWLock<T>[src]

The RWLock is always Sync, to make it Send as well it need to be wrapped into an Arc.

Auto Trait Implementations

impl<T: ?Sized> Send for RWLock<T> where
    T: Send

impl<T: ?Sized> Unpin for RWLock<T> where
    T: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.