Struct loom::sync::RwLock[][src]

pub struct RwLock<T> { /* fields omitted */ }

Mock implementatoin of std::sync::RwLock

Implementations

impl<T> RwLock<T>[src]

pub fn new(data: T) -> RwLock<T>[src]

Creates a new rwlock in an unlocked state ready for use.

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

Locks this rwlock with shared read access, blocking the current thread until it can be acquired.

The calling thread will be blocked until there are no more writers which hold the lock. There may be other readers currently inside the lock when this method returns. This method does not provide any guarantees with respect to the ordering of whether contentious readers or writers will acquire the lock first.

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

Attempts to acquire this rwlock with shared read access.

If the access could not be granted at this time, then Err is returned. Otherwise, an RAII guard is returned which will release the shared access when it is dropped.

This function does not block.

pub fn write(&self) -> LockResult<RwLockWriteGuard<'_, T>>[src]

Locks this rwlock with exclusive write access, blocking the current thread until it can be acquired.

This function will not return while other writers or other readers currently have access to the lock.

pub fn try_write(&self) -> TryLockResult<RwLockWriteGuard<'_, T>>[src]

Attempts to lock this rwlock with exclusive write access.

If the lock could not be acquired at this time, then Err is returned. Otherwise, an RAII guard is returned which will release the lock when it is dropped.

This function does not block.

pub fn into_inner(self) -> LockResult<T>[src]

Consumes this RwLock, returning the underlying data.

Trait Implementations

impl<T: Debug> Debug for RwLock<T>[src]

impl<T: Default> Default for RwLock<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for RwLock<T>

impl<T> Send for RwLock<T> where
    T: Send

impl<T> Sync for RwLock<T> where
    T: Send + Sync

impl<T> Unpin for RwLock<T> where
    T: Unpin

impl<T> UnwindSafe for RwLock<T>

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.