xwrust::xwos::sync::cond

Struct CondSel

source
pub struct CondSel<'a, const M: XwSz>
where [XwBmp; { _ }]: Sized,
{ /* private fields */ }
Expand description

条件量的选择子

CondSel<'a, M>CondSel<M> 具有相同的生命周期约束 'a 。因为 CondSel<'a, M> 中包含了 CondSel<M> 的引用。

CondSel<'a, M> 中包含了绑定的位置信息,条件量采用 非独占 的方式进行绑定。

CondSel::selected() 可用来判断条件量是否被选择。

CondSel<'a, M>drop() 时,会自动将 CondSel<M> 解绑。

Implementations§

source§

impl<'a, const M: XwSz> CondSel<'a, M>
where [XwBmp; { _ }]: Sized,

source

pub fn selected(&self, trg: &Bmp<M>) -> bool

判断触发的 选择信号 是否包括此条件量

§示例
    let msk = Bmp::<8>::new(); // 8位位图
    msk.s1all(); // 掩码为0xFF
    loop {
        let res = sel.select(&msk);
        match res {
            Ok(t) => { // 信号选择器上有 **选择信号** , `t` 为 **选择信号** 的位图。
                if cond0sel.selected(&t) { // 条件量0被选择到
                }
                if cond1sel.selected(&t) { // 条件量1被选择到
                }
            },
            Err(e) => { // 等待信号选择器失败,`e` 为 `SelError`
                break;
            },
        }
    }

Trait Implementations§

source§

impl<'a, const M: XwSz> Drop for CondSel<'a, M>
where [XwBmp; { _ }]: Sized,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a, const M: XwSz> Send for CondSel<'a, M>
where [XwBmp; { _ }]: Sized,

source§

impl<'a, const M: XwSz> Sync for CondSel<'a, M>
where [XwBmp; { _ }]: Sized,

Auto Trait Implementations§

§

impl<'a, const M: usize> Freeze for CondSel<'a, M>
where [usize; { _ }]: Sized,

§

impl<'a, const M: usize> !RefUnwindSafe for CondSel<'a, M>

§

impl<'a, const M: usize> Unpin for CondSel<'a, M>
where [usize; { _ }]: Sized,

§

impl<'a, const M: usize> !UnwindSafe for CondSel<'a, M>

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.