15 #ifndef RCLCPP__WAIT_RESULT_HPP_
16 #define RCLCPP__WAIT_RESULT_HPP_
24 #include "rclcpp/macros.hpp"
25 #include "rclcpp/wait_result_kind.hpp"
53 template<
class WaitSetT>
67 return WaitResult(WaitResultKind::Ready, wait_set);
90 return wait_result_kind_;
101 if (this->
kind() != WaitResultKind::Ready) {
102 throw std::runtime_error(
"cannot access wait set when the result was not ready");
105 assert(wait_set_pointer_);
106 return *wait_set_pointer_;
117 if (this->
kind() != WaitResultKind::Ready) {
118 throw std::runtime_error(
"cannot access wait set when the result was not ready");
121 assert(wait_set_pointer_);
122 return *wait_set_pointer_;
126 : wait_result_kind_(other.wait_result_kind_),
127 wait_set_pointer_(std::exchange(other.wait_set_pointer_,
nullptr))
132 if (wait_set_pointer_) {
133 wait_set_pointer_->wait_result_release();
138 RCLCPP_DISABLE_COPY(WaitResult)
140 explicit WaitResult(WaitResultKind wait_result_kind)
141 : wait_result_kind_(wait_result_kind)
144 assert(WaitResultKind::Ready != wait_result_kind);
147 WaitResult(WaitResultKind wait_result_kind, WaitSetT & wait_set)
148 : wait_result_kind_(wait_result_kind),
149 wait_set_pointer_(&wait_set)
152 assert(WaitResultKind::Ready == wait_result_kind);
154 wait_set_pointer_->wait_result_acquire();
157 const WaitResultKind wait_result_kind_;
159 WaitSetT * wait_set_pointer_ =
nullptr;
Interface for introspecting a wait set after waiting on it.
static WaitResult from_ready_wait_result_kind(WaitSetT &wait_set)
Create WaitResult from a "ready" result.
static WaitResult from_empty_wait_result_kind()
Create WaitResult from a "empty" result.
static WaitResult from_timeout_wait_result_kind()
Create WaitResult from a "timeout" result.
const WaitSetT & get_wait_set() const
Return the rcl wait set.
WaitResultKind kind() const
Return the kind of the WaitResult.
WaitSetT & get_wait_set()
Return the rcl wait set.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.