FusedRwLock

Struct FusedRwLock 

Source
pub struct FusedRwLock<T: ?Sized> { /* private fields */ }
Expand description

A special RwLock which can be locked exclusively any number of consecutive times, but once initially locked shared, can never be unlocked. This allows unguarded reads to occur

Implementations§

Source§

impl<T> FusedRwLock<T>

Source

pub const fn new(x: T) -> Self

Constructs a new, initially unlocked, RwLock

Source

pub fn into_inner(self) -> T

Moves the inner value out of the FusedRwLock. This is sound because self is moved into the function, and thus no other accesses exist

Source§

impl<T: ?Sized> FusedRwLock<T>

Source

pub fn try_get_mut(&mut self) -> Option<&mut T>

Mutably borrows the interior of the lock, if it has not been locked for reading access This is sound because taking self by &mut statically guarantees no other accesses exist. Returns None if the lock has been locked for reading

Source

pub unsafe fn get_mut_unlocked(&mut self) -> &mut T

Mutably borrows the interior of the lock, even if it has been locked for reading. This function is unsafe because, while not necessarily undefined behaviour, calling this function after it was locked for reading can be used to violate the logical invariant of FusedRwLock.

Source

pub fn is_locked(&self) -> bool

Check if the FusedRwLock has been locked for reading. This does not guarantee any synchronization, even if it returns true. Except where self is reborrowed from &mut, it should only be used as a hint to avoid needless calls to self.try_read A return of true is guaranteed to remain true for the lifetime of the lock. A return of false may be invalidated at any time.

Source

pub fn lock(&self)

Locks this FusedRwLock for reading. After this call, it becomes impossible to acquire the lock for writing, and safe code cannot be used to modify the inner value (except inside an UnsafeCell)

Source

pub fn try_read(&self) -> Option<&T>

Returns a shared reference to the interior of the lock, if it has been locked for reading.

Source

pub fn read(&self) -> &T

Locks the RwLock for reading, and returns a shared reference to the interior of the lock

Source

pub fn try_write(&self) -> Option<FusedRwLockGuard<'_, T>>

Acquires an exclusive lock to the interior of the lock, if this lock has not already been locked for reading. Otherwise, returns None

Trait Implementations§

Source§

impl<T: Default> Default for FusedRwLock<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: ?Sized + Send> Send for FusedRwLock<T>

Source§

impl<T: ?Sized + Send + Sync> Sync for FusedRwLock<T>

Auto Trait Implementations§

§

impl<T> !Freeze for FusedRwLock<T>

§

impl<T> !RefUnwindSafe for FusedRwLock<T>

§

impl<T> Unpin for FusedRwLock<T>
where T: Unpin + ?Sized,

§

impl<T> UnwindSafe for FusedRwLock<T>
where T: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.