xwrust::xwos::lock::seqlock

Struct SeqlockReadGuard

source
pub struct SeqlockReadGuard<'a, T: ?Sized + 'a> { /* private fields */ }
Expand description

顺序锁共享读临界区的守卫

共享读临界区的守卫只提供解引用到只读引用。

Implementations§

source§

impl<'a, T: ?Sized> SeqlockReadGuard<'a, T>

source

pub fn read_retry(&self) -> bool

关闭共享读临界区,并检查是否需要重试

  • 当顺序锁的顺序值没有发生变化,返回 [false] ;
  • 当顺序锁的顺序值发生了变化,返回 [true] 。
§示例
loop {
    let guard = sqlk.read_begin();
    let val = *guard;
    if !guard.read_retry() {
        break;
    }
}

Trait Implementations§

source§

impl<T: ?Sized> Deref for SeqlockReadGuard<'_, T>

source§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T: ?Sized> !Send for SeqlockReadGuard<'_, T>

source§

impl<T: ?Sized + Sync> Sync for SeqlockReadGuard<'_, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for SeqlockReadGuard<'a, T>
where T: ?Sized,

§

impl<'a, T> !RefUnwindSafe for SeqlockReadGuard<'a, T>

§

impl<'a, T> Unpin for SeqlockReadGuard<'a, T>
where T: ?Sized,

§

impl<'a, T> !UnwindSafe for SeqlockReadGuard<'a, T>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.