ROS 2 rclcpp + rcl - rolling  rolling-a919a6e5
ROS 2 C++ Client Library with ROS Client Library
Public Member Functions | Static Public Member Functions | List of all members
rclcpp::WaitResult< WaitSetT > Class Template Referencefinal

Interface for introspecting a wait set after waiting on it. More...

#include <rclcpp/wait_result.hpp>

Public Member Functions

WaitResultKind kind () const
 Return the kind of the WaitResult.
 
const WaitSetT & get_wait_set () const
 Return the rcl wait set. More...
 
WaitSetT & get_wait_set ()
 Return the rcl wait set. More...
 
 WaitResult (WaitResult &&other) noexcept
 
std::pair< std::shared_ptr< rclcpp::TimerBase >, size_t > peek_next_ready_timer (size_t start_index=0)
 Get the next ready timer and its index in the wait result, but do not clear it. More...
 
void clear_timer_with_index (size_t index)
 Clear the timer at the given index. More...
 
std::shared_ptr< rclcpp::SubscriptionBasenext_ready_subscription ()
 Get the next ready subscription, clearing it from the wait result.
 
std::shared_ptr< rclcpp::ServiceBasenext_ready_service ()
 Get the next ready service, clearing it from the wait result.
 
std::shared_ptr< rclcpp::ClientBasenext_ready_client ()
 Get the next ready client, clearing it from the wait result.
 
std::shared_ptr< rclcpp::Waitablenext_ready_waitable ()
 Get the next ready waitable, clearing it from the wait result.
 

Static Public Member Functions

static WaitResult from_ready_wait_result_kind (WaitSetT &wait_set)
 Create WaitResult from a "ready" result. More...
 
static WaitResult from_timeout_wait_result_kind ()
 Create WaitResult from a "timeout" result.
 
static WaitResult from_empty_wait_result_kind ()
 Create WaitResult from a "empty" result.
 

Detailed Description

template<class WaitSetT>
class rclcpp::WaitResult< WaitSetT >

Interface for introspecting a wait set after waiting on it.

This class:

This class is only valid as long as the wait set which created it is valid, and it must be deleted before the wait set is deleted, as it contains a back reference to the wait set.

An instance of this, which is returned from rclcpp::WaitSetTemplate::wait(), will cause the wait set to keep ownership of the entities because it only holds a reference to the sequences of them, rather than taking a copy. Also, in the thread-safe case, an instance of this will cause the wait set, to block calls which modify the sequences of the entities, e.g. add/remove guard condition or subscription methods.

Template Parameters
WaitSetTThe wait set type which created this class.

Definition at line 62 of file wait_result.hpp.

Member Function Documentation

◆ clear_timer_with_index()

template<class WaitSetT >
void rclcpp::WaitResult< WaitSetT >::clear_timer_with_index ( size_t  index)
inline

Clear the timer at the given index.

Clearing a timer from the wait result prevents it from being returned by the peek_next_ready_timer() on subsequent calls.

The index should come from the peek_next_ready_timer() function, and should only be used with this function if the timer pointer was valid.

Exceptions
std::out_of_rangeif the given index is out of range

Definition at line 199 of file wait_result.hpp.

References rclcpp::WaitResult< WaitSetT >::get_wait_set().

Here is the call graph for this function:

◆ from_ready_wait_result_kind()

template<class WaitSetT >
static WaitResult rclcpp::WaitResult< WaitSetT >::from_ready_wait_result_kind ( WaitSetT &  wait_set)
inlinestatic

Create WaitResult from a "ready" result.

Parameters
[in]wait_setA reference to the wait set, which this class will keep for the duration of its lifetime.
Returns
a WaitResult from a "ready" result.

Definition at line 73 of file wait_result.hpp.

◆ get_wait_set() [1/2]

template<class WaitSetT >
WaitSetT& rclcpp::WaitResult< WaitSetT >::get_wait_set ( )
inline

Return the rcl wait set.

Returns
rcl wait set.
Exceptions
std::runtime_errorif the class cannot access wait set when the result was not ready

Definition at line 123 of file wait_result.hpp.

References rclcpp::WaitResult< WaitSetT >::kind().

Here is the call graph for this function:

◆ get_wait_set() [2/2]

template<class WaitSetT >
const WaitSetT& rclcpp::WaitResult< WaitSetT >::get_wait_set ( ) const
inline

Return the rcl wait set.

Returns
const rcl wait set.
Exceptions
std::runtime_errorif the class cannot access wait set when the result was not ready

Definition at line 107 of file wait_result.hpp.

References rclcpp::WaitResult< WaitSetT >::kind().

Referenced by rclcpp::WaitResult< WaitSetT >::clear_timer_with_index(), rclcpp::WaitResult< WaitSetT >::next_ready_client(), rclcpp::WaitResult< WaitSetT >::next_ready_service(), rclcpp::WaitResult< WaitSetT >::next_ready_subscription(), rclcpp::WaitResult< WaitSetT >::next_ready_waitable(), and rclcpp::WaitResult< WaitSetT >::peek_next_ready_timer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peek_next_ready_timer()

template<class WaitSetT >
std::pair<std::shared_ptr<rclcpp::TimerBase>, size_t> rclcpp::WaitResult< WaitSetT >::peek_next_ready_timer ( size_t  start_index = 0)
inline

Get the next ready timer and its index in the wait result, but do not clear it.

The returned timer is not cleared automatically, as it the case with the other next_ready_*()-like functions. Instead, this function returns the timer and the index that identifies it in the wait result, so that it can be cleared (marked as taken or used) in a separate step with clear_timer_with_index(). This is necessary in some multi-threaded executor implementations.

If the timer is not cleared using the index, subsequent calls to this function will return the same timer.

If there is no ready timer, then nullptr will be returned and the index will be invalid and should not be used.

Parameters
[in]start_indexindex at which to start searching for the next ready timer in the wait result. If the start_index is out of bounds for the list of timers in the wait result, then {nullptr, start_index} will be returned. Defaults to 0.
Returns
next ready timer pointer and its index in the wait result, or {nullptr, start_index} if none was found.

Definition at line 168 of file wait_result.hpp.

References rclcpp::WaitResult< WaitSetT >::get_wait_set(), and rclcpp::WaitResult< WaitSetT >::kind().

Here is the call graph for this function:

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