nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
GuardCondition Class Reference

#include <guard_condition.hpp>

Public Member Functions

void attach_closure_block (detail::HostedBlockBase *block)
Result clear ()
 GuardCondition ()
 GuardCondition (GuardCondition &&other)
bool is_triggered () const
bool is_valid () const
 Check if the guard condition is initialized and valid.
GuardCondition & operator= (GuardCondition &&other)
Result trigger ()
 ~GuardCondition ()

Friends

class ::rclcpp::Node

Constructor & Destructor Documentation

◆ ~GuardCondition()

GuardCondition::~GuardCondition ( )
inline

Destructor — releases the guard condition (issue 1667): its executor entry is freed, so spin_once stops polling it and the callback slot goes back to NROS_EXECUTOR_MAX_CBS. Sound because this object is non-copyable and the only holder of the trigger handle; trigger it from another thread only while it is alive.

◆ GuardCondition() [1/2]

GuardCondition::GuardCondition ( GuardCondition && other)
inline

◆ GuardCondition() [2/2]

GuardCondition::GuardCondition ( )
inline

Default constructor — creates an uninitialized guard condition. Use Node::create_guard_condition() to initialize.

Member Function Documentation

◆ attach_closure_block()

void GuardCondition::attach_closure_block ( detail::HostedBlockBase * block)
inline

◆ clear()

Result GuardCondition::clear ( )
inline

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

◆ is_triggered()

bool GuardCondition::is_triggered ( ) const
inline

Is this guard condition triggered and not yet dispatched?

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

The executor CONSUMES the flag when it dispatches, so this answers "set and not yet dispatched": poll it or take the callback, not both.

◆ is_valid()

bool GuardCondition::is_valid ( ) const
inline

Check if the guard condition is initialized and valid.

◆ operator=()

GuardCondition & GuardCondition::operator= ( GuardCondition && other)
inline

◆ trigger()

Result GuardCondition::trigger ( )
inline

Trigger the guard condition (thread-safe, lock-free).

The callback will be invoked on the next spin_once().

◆ ::rclcpp::Node

friend class ::rclcpp::Node
friend

The documentation for this class was generated from the following file: