Class TimerQueue

Nested Relationships

Nested Types

Class Documentation

class TimerQueue

A class for managing a queue of timers.

This class holds a queue of timers of one type (RCL_ROS_TIME, RCL_SYSTEM_TIME or RCL_STEADY_TIME). The queue itself manages an internal map of the timers, orders by the next time a timer will be ready. Each time a timer is ready, a callback will be called from the internal thread.

Public Functions

inline TimerQueue(rcl_clock_type_t timer_type, const rclcpp::Context::SharedPtr &context)
inline ~TimerQueue()
inline void stop()
inline void remove_timer(const rclcpp::TimerBase::SharedPtr &timer)

Removes a new timer from the queue. This function is thread safe.

Removes a timer, if it was added to this queue. Ignores timers that are not part of this queue

Parameters:

timer – the timer to remove.

inline void add_timer(const rclcpp::TimerBase::SharedPtr &timer, const std::function<void(const std::function<void()> executed_cb)> &timer_ready_callback)

Adds a new timer to the queue. This function is thread safe.

This function will ignore any timer, that has not a matching type

Parameters:
  • timer – the timer to add.

  • timer_ready_callback – callback that should be called when the timer is ready.