10#ifndef NROS_RCLCPP_TIMER_HPP
11#define NROS_RCLCPP_TIMER_HPP
17#include "rclcpp/detail/hosted_block.hpp"
21#include "rclcpp/duration.hpp"
28#include "rclcpp/detail/nros_cpp_ffi.h"
79 return Duration::from_nanoseconds(
ns);
83 constexpr TimerOps(
void* executor,
size_t handle_id)
153 return a.executor_ ==
b.executor_ &&
a.handle_id_ ==
b.handle_id_;
159 return a.executor_ ==
nullptr;
162 return a.executor_ !=
nullptr;
165 return a.executor_ ==
nullptr;
168 return a.executor_ !=
nullptr;
221 if (!initialized_)
return true;
238 if (!initialized_)
return false;
266 if (!initialized_)
return Duration();
271 return Duration::from_nanoseconds(
ns);
281 initialized_ =
false;
285 detail::destroy_hosted_block(closure_);
290 : executor_(
other.executor_), handle_id_(
other.handle_id_),
291 initialized_(
other.initialized_), closure_(
other.closure_) {
292 other.executor_ =
nullptr;
293 other.initialized_ =
false;
294 other.closure_ =
nullptr;
298 if (
this != &
other) {
302 executor_ =
other.executor_;
303 handle_id_ =
other.handle_id_;
304 initialized_ =
other.initialized_;
305 detail::destroy_hosted_block(closure_);
306 closure_ =
other.closure_;
307 other.executor_ =
nullptr;
308 other.initialized_ =
false;
309 other.closure_ =
nullptr;
330 detail::destroy_hosted_block(closure_);
338 friend class ::rclcpp::Node;
Definition client.hpp:129
Definition result.hpp:216
friend constexpr bool operator!=(decltype(nullptr), const TimerHandle &a)
Definition timer.hpp:167
constexpr TimerHandle(decltype(nullptr))
Definition timer.hpp:125
friend constexpr bool operator==(decltype(nullptr), const TimerHandle &a)
Definition timer.hpp:164
friend constexpr bool operator==(const TimerHandle &a, decltype(nullptr))
Definition timer.hpp:158
constexpr TimerHandle(void *executor, size_t handle_id)
Definition timer.hpp:126
constexpr TimerHandle()
Definition timer.hpp:122
friend constexpr bool operator!=(const TimerHandle &a, const TimerHandle &b)
Definition timer.hpp:155
friend constexpr bool operator==(const TimerHandle &a, const TimerHandle &b)
Definition timer.hpp:152
constexpr size_t handle_id() const
The packed executor handle this refers to. For introspection and tests.
Definition timer.hpp:150
TimerOps * operator->()
timer_->cancel() and friends.
Definition timer.hpp:134
void reset()
Definition timer.hpp:141
friend constexpr bool operator!=(const TimerHandle &a, decltype(nullptr))
Definition timer.hpp:161
const TimerOps * operator->() const
Const overload of operator->.
Definition timer.hpp:136
Duration time_until_trigger() const
Definition timer.hpp:73
constexpr TimerOps(void *executor, size_t handle_id)
Definition timer.hpp:83
Result cancel()
Stop the timer firing. It stays registered; reset() restarts it.
Definition timer.hpp:52
bool is_ready() const
Definition timer.hpp:65
bool is_canceled() const
Definition timer.hpp:59
void * executor_
Definition timer.hpp:86
Result reset()
Restart the timer from zero elapsed time; un-cancels a cancelled one.
Definition timer.hpp:55
size_t handle_id_
Definition timer.hpp:87
void attach_closure_block(detail::HostedBlockBase *block)
Definition timer.hpp:329
Timer()
Definition timer.hpp:316
Result reset()
Definition timer.hpp:214
Result cancel()
Definition timer.hpp:207
bool is_ready() const
Definition timer.hpp:237
bool is_valid() const
Check if the timer is initialized and valid.
Definition timer.hpp:275
Duration time_until_trigger() const
Definition timer.hpp:265
Timer & operator=(Timer &&other)
Definition timer.hpp:297
Timer(Timer &&other)
Definition timer.hpp:289
~Timer()
Destructor — cancels the timer.
Definition timer.hpp:278
bool is_canceled() const
Check if the timer is cancelled.
Definition timer.hpp:220
ResultOf< void > Result
Definition result.hpp:246
rclcpp::Result, rclcpp::ErrorCode, and the RCLCPP_TRY macro.