[−][src]Struct seqlock::SeqLock
A sequential lock
Implementations
impl<T: Copy> SeqLock<T>
[src]
pub fn new(val: T) -> SeqLock<T>
[src]
Creates a new SeqLock with the given initial value.
pub fn read(&self) -> T
[src]
Reads the value protected by the SeqLock
.
This operation is extremely fast since it only reads the SeqLock
,
which allows multiple readers to read the value without interfering with
each other.
If a writer is currently modifying the contained value then the calling thread will block until the writer thread releases the lock.
Attempting to read from a SeqLock
while already holding a write lock
in the current thread will result in a deadlock.
pub fn lock_write(&self) -> SeqLockGuard<'_, T>
[src]
Locks this SeqLock
with exclusive write access, blocking the current
thread until it can be acquired.
This function does not block while waiting for concurrent readers. Instead, readers will detect the concurrent write and retry the read.
Returns an RAII guard which will drop the write access of this SeqLock
when dropped.
pub fn try_lock_write(&self) -> Option<SeqLockGuard<'_, T>>
[src]
Attempts to lock this SeqLock
with exclusive write access.
If the lock could not be acquired at this time, then None
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) -> T
[src]
Consumes this SeqLock
, returning the underlying data.
pub fn get_mut(&mut self) -> &mut T
[src]
Returns a mutable reference to the underlying data.
Since this call borrows the SeqLock
mutably, no actual locking needs
to take place---the mutable borrow statically guarantees no locks exist.
Trait Implementations
impl<T: Copy + Debug> Debug for SeqLock<T>
[src]
impl<T: Copy + Default> Default for SeqLock<T>
[src]
impl<T: Copy + Send> Send for SeqLock<T>
[src]
impl<T: Copy + Send> Sync for SeqLock<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for SeqLock<T>
impl<T> Unpin for SeqLock<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for SeqLock<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,