Skip to main content

GuardCondition

Struct GuardCondition 

Source
pub struct GuardCondition { /* private fields */ }
Expand description

Handle for triggering a guard condition from outside the executor.

Obtained from Executor::register_guard_condition. Safe to use from any thread — the inner &'static AtomicBool is inherently Send + Sync.

Implementations§

Source§

impl GuardCondition

Source

pub fn trigger(&self)

Trigger the guard condition.

The executor will invoke the associated callback on the next spin iteration. On std + rmw-cffi builds, trigger also signals the executor’s wake condvar so a blocked spin_once resumes immediately.

Source

pub fn is_triggered(&self) -> bool

Is this guard condition triggered and not yet dispatched?

The RFC-0022 POLLING tier: a task that owns its own loop and never reaches a callback still needs to see the flag another thread or an ISR set. rcl has no such reader — a wait set is the only way to observe an rcl guard condition — so this is ours, and phase-417 W4.e gave Rust and C++ the reader C already had.

Bounded claim: the executor CONSUMES the flag when it dispatches (guard_try_process swaps it false and then calls the callback), so this answers “set and not yet dispatched”. A poller that also spins the executor is racing itself, and should read the flag OR take the callback, not both.

Source

pub fn clear(&self) -> bool

Clear the flag without dispatching — the other half of is_triggered, for a polling owner that has just handled the event itself.

Returns what the flag WAS, so a poller can take-and-clear in one step without a read/clear race against another thread’s trigger.

Trait Implementations§

Source§

impl Clone for GuardCondition

phase-467 Row 8 — a SECOND handle to the same arena flag.

Sound by construction: every field is Copy, the flag is a &'static reference into an arena that outlives every handle, and trigger() is a store plus a wake — there is no ownership to duplicate and nothing to free. is_triggered/clear are already documented as racing an executor that dispatches, so a second handle adds no contract.

Written rather than derived so the reason is here: the graph-change edge needs one handle in the CALLER’s rcl_guard_condition_t and one the EXECUTOR owns for the backend to fire (issue 1385’s shape). Not Copy — an implicit copy of a trigger handle reads as a value and behaves as an alias, which is exactly the confusion the 1385 fix is about.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Send for GuardCondition

Source§

impl Sync for GuardCondition

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

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.