xwrust::xwos::sync::br

Struct BrSel

source
pub struct BrSel<'a, const N: XwSz, const M: XwSz>
where [XwBmp; { _ }]: Sized,
{ pub br: &'a Br<N>, pub sel: &'a Sel<M>, pub pos: XwSq, }
Expand description

线程栅栏的选择子

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

BrSel<'a, N, M> 中包含了绑定的位置信息,线程栅栏采用 非独占 的方式进行绑定。

BrSel::selected() 可用来判断线程栅栏是否被选择。

BrSel<'a, N, M>drop() 时,会自动将 Br<N>Sel<M> 解绑。

Fields§

§br: &'a Br<N>

线程栅栏

§sel: &'a Sel<M>

信号选择器

§pos: XwSq

位置

Implementations§

source§

impl<'a, const N: XwSz, const M: XwSz> BrSel<'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 br0sel.selected(&t) { // 线程栅栏被选择到
                }
            },
            Err(e) => { // 等待信号选择器失败,`e` 为 `SelError`
                break;
            },
        }
    }

Trait Implementations§

source§

impl<'a, const N: XwSz, const M: XwSz> Drop for BrSel<'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 BrSel<'a, N, M>
where [XwBmp; { _ }]: Sized,

source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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