xwrust::xwos::sync::sel

Struct SelSel

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

信号选择器的选择子

SelSel<'a, N, M> 与源信号选择器 src 与 目的信号选择器 dst 具有相同的生命周期约束 'a 。因为 SelSel<'a, N, M> 中的 srcdst 是引用。

SelSel<'a, N, M> 中包含了绑定的位置,信号选择器 采用 非独占 的方式进行绑定。

选择信号 首先从其他 同步对象 发送给 src ,再由 src 传递给 dst

SelSel::selected() 可用来判断信号选择器是否被选择。

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

Implementations§

source§

impl<'a, const N: XwSz, const M: XwSz> SelSel<'a, N, 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 sel0sel.selected(&t) { // 信号选择器0被选择到
                    let msk0 = Bmp::<16>::new(); // 16位位图
                    msk0.s1all(); // 掩码为0xFFFF
                    let res0 = sel0.tryselect(msk0); // 继续从sel0中选择
                    match res0 {
                        Ok(t0) => { // 信号选择器0上有 **选择信号** , `t0` 为 **选择信号** 的位图。
                        },
                        Err(e0) => { // 等待信号选择器0失败,`e` 为 `SelError`
                        },
                    }
                }
            },
            Err(e) => { // 等待信号选择器失败,`e` 为 `SelError`
                break;
            },
        }
    }

Trait Implementations§

source§

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

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

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

source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

impl<'a, const N: usize, const M: usize> !UnwindSafe for SelSel<'a, N, 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.