Skip to main content

VetoGate

Struct VetoGate 

Source
pub struct VetoGate<const N: usize> { /* private fields */ }
Expand description

A gate that is asserted while any of its N contributors holds it and released only once all of them have let go.

The shape of a trip matrix or a safety chain: every protection function writing the gate may force the safe state, and no single one can clear another’s contribution. Writers declare writes: [crate::TRIP veto]; the graph numbers them — one slot per node, one per pool member — and proves at compile time that the target is a VetoGate with room for them all. A writer takes its handle with TaskNode::veto and asserts or releases its own bit; the actuator reads the gate through reads: and parks on wait_asserted / wait_released.

A contributor’s bit stays asserted when its writer stops: a dead protection function keeps the trip. Release is explicit — the writer’s own Veto::release, or the application through release_slot. Costs one AtomicU32 and one Signal per gate (plus a transition counter under coupling-observe).

Implementations§

Source§

impl<const N: usize> VetoGate<N>

Source

pub const fn new() -> Self

A released gate (const — it lives in a static).

Source

pub fn is_asserted(&self) -> bool

Is any contributor holding the gate?

Source

pub fn contributors(&self) -> u32

The contributors currently asserting, one bit per slot.

Source

pub fn assert_slot(&self, slot: u8) -> bool

Assert contributor slot. Returns whether the gate flipped from released to asserted.

Source

pub fn release_slot(&self, slot: u8) -> bool

Release contributor slot. Returns whether the gate flipped from asserted to released — only once the last contributor lets go.

Source

pub async fn wait_asserted(&self)

Park until the gate is asserted (returns at once if it already is).

Source

pub async fn wait_released(&self)

Park until every contributor has released the gate.

Trait Implementations§

Source§

impl<const N: usize> Default for VetoGate<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> Observable for VetoGate<N>

Available on crate feature coupling-observe only.
Source§

fn change_token(&self) -> u32

Return a token that changes when the signal is written.

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for VetoGate<N>

§

impl<const N: usize> !RefUnwindSafe for VetoGate<N>

§

impl<const N: usize> Send for VetoGate<N>

§

impl<const N: usize> Sync for VetoGate<N>

§

impl<const N: usize> Unpin for VetoGate<N>

§

impl<const N: usize> UnsafeUnpin for VetoGate<N>

§

impl<const N: usize> UnwindSafe for VetoGate<N>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CouplingPoint for T
where T: Sync + ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.