#include <timer.hpp>
◆ ConstSharedPtr
◆ SharedPtr
Timer::SharedPtr — how a timer member is declared: rclcpp::Timer::SharedPtr timer_; (or rclcpp::TimerBase::SharedPtr, the alias below).
phase-476 W2 — a [TimerHandle], not a std::shared_ptr<Timer>, and UNCONDITIONAL: the timer's callable lives in the executor arena, so the C++ side owns nothing a smart pointer could hold, and a freestanding target gets the ported spelling too. See TimerHandle for what differs from a shared_ptr (it does not own the timer; .reset() releases it).
◆ UniquePtr
Timer::UniquePtr — the same handle; see SharedPtr. Upstream's is a sole owner. This one owns nothing, like the other two spellings.
◆ ~Timer()
Destructor — cancels the timer.
◆ Timer() [1/2]
| Timer::Timer |
( |
Timer && | other | ) |
|
|
inline |
◆ Timer() [2/2]
Default constructor — creates an uninitialized timer. Use Node::create_wall_timer() to initialize.
◆ attach_closure_block()
| void Timer::attach_closure_block |
( |
detail::HostedBlockBase * | block | ) |
|
|
inline |
◆ cancel()
Cancel the timer. It stops firing but remains in the executor. Use reset() to restart it. On the std surface the result may be ignored (detail::StatementResult).
◆ get_clock()
| detail::ClockValuePtr Timer::get_clock |
( |
| ) |
const |
|
inline |
The clock this timer runs on – rclcpp's TimerBase::get_clock(). issue 1975.
A wall timer (create_wall_timer) answers RCL_STEADY_TIME, as rclcpp's wall timers do; a create_timer(clock, …) timer answers the clock it was created with. The answer is the EXECUTOR's – the clock field the dispatcher reads – so it cannot drift from what actually advances the timer.
ADOPT-BOUNDED. Upstream returns const Clock::SharedPtr&; this returns a [detail::ClockValuePtr], the clock held by value behind -> and *, because there is no allocator to share one from (RFC-0022) and the clock owns nothing a copy could lose. timer->get_clock()->now() keeps its spelling. An uninitialized timer answers a value whose operator bool is false and whose clock reads zero.
◆ is_canceled()
| bool Timer::is_canceled |
( |
| ) |
const |
|
inline |
Check if the timer is cancelled.
◆ is_ready()
| bool Timer::is_ready |
( |
| ) |
const |
|
inline |
Would this timer fire on the next spin_once() pass? — rclcpp's TimerBase::is_ready().
phase-417 G6. The answer is the EXECUTOR's, read from the arena entry the timer is registered in: a cancelled timer is never ready, a fired one-shot is never ready again, and otherwise elapsed >= period. That is arena::timer_try_process's own guard rather than a second opinion about it — a readiness answer that can disagree with the dispatcher is worse than no answer.
An uninitialized timer answers false: it is registered with no executor, so nobody will dispatch it.
◆ is_valid()
| bool Timer::is_valid |
( |
| ) |
const |
|
inline |
Check if the timer is initialized and valid.
◆ operator=()
◆ reset()
Reset the timer (restart from zero elapsed time). If cancelled, this also un-cancels it.
◆ time_until_trigger()
| Duration Timer::time_until_trigger |
( |
| ) |
const |
|
inline |
Time until this timer next fires — NEGATIVE when it is overdue. rclcpp's TimerBase::time_until_trigger().
phase-417 G6. Two deliberate differences from rclcpp, both recorded on the ledger row:
- upstream returns std::chrono::nanoseconds; this returns [rclcpp::Duration], because this header is freestanding and <chrono> is not reachable from every target it serves (issue 0112). The UNIT is the same — d.nanoseconds() is upstream's count.
- the arena's timer accounting is MICROSECOND-based (issue #505), so the nanosecond value is a microsecond quantity scaled by 1000. The unit is rclcpp's; the resolution is ours.
A wall timer answers on the platform steady clock; a timer created with create_timer(clock, …) answers on its own clock.
Duration() (zero) for an uninitialized timer or one the executor does not know. That collides with "fires exactly now", which is why [is_valid] is the question to ask first — the C surface spends a return code on the distinction (rcl_timer_get_time_until_next_call answers RCL_RET_NOT_INIT) and a Duration-returning accessor has no room for one.
◆ ::rclcpp::Node
The documentation for this class was generated from the following file: