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
impl GuardCondition
Sourcepub fn trigger(&self)
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.
Sourcepub fn is_triggered(&self) -> bool
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.
Sourcepub fn clear(&self) -> bool
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.
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.