|
mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
|
Handle to a registered timeout, that unregisters it on destruction. More...
#include <timeout_manager.hpp>
Public Member Functions | |
| TimeoutManagerHandle (internal::TimeoutManagerHandleKey key, TimeoutManagerRegisterOptions options, std::shared_ptr< rclcpp::node_interfaces::NodeClockInterface > clock_interface) | |
| Construct the handle. | |
| ~TimeoutManagerHandle ()=default | |
| Default destructor. | |
| TimeoutManagerHandle (const TimeoutManagerHandle &)=delete | |
| TimeoutManagerHandle is immovable. | |
| TimeoutManagerHandle & | operator= (const TimeoutManagerHandle &)=delete |
| TimeoutManagerHandle is immovable. | |
| TimeoutManagerHandle (TimeoutManagerHandle &&)=delete | |
| TimeoutManagerHandle is immovable. | |
| TimeoutManagerHandle & | operator= (TimeoutManagerHandle &&)=delete |
| TimeoutManagerHandle is immovable. | |
| void | reset_timeout () |
| Reset the timeout countdown. | |
| void | start () |
| Start the timeout. | |
| void | pause () |
| Stop the timeout. | |
| void | set_timeout (std::chrono::nanoseconds timeout) |
| Set a new duration after which the timeout is called. | |
| bool | is_started () const |
| Check if the timeout is started. | |
| rclcpp::Time | get_last_reset () const |
| Get time of last call to reset. | |
| void | run_callback_if_expired (internal::TimeoutManagerHandleKey key) |
| Check if timeout is expired and if yes, call it. | |
Handle to a registered timeout, that unregisters it on destruction.
|
explicit |
Construct the handle.
| key | Key type to prevent users from calling this function. |
| options | Options to configure the timeout. |
| clock_interface | Clock interface to use for obtaining current time. |
|
nodiscard |
Get time of last call to reset.
|
nodiscard |
Check if the timeout is started.
| void mrs_lib::TimeoutManagerHandle::pause | ( | ) |
Stop the timeout.
After this call, new timeout callbacks won't be called until a call to start.
| void mrs_lib::TimeoutManagerHandle::reset_timeout | ( | ) |
Reset the timeout countdown.
If this function is not called before the timeout expires, the configured callback is called.
| void mrs_lib::TimeoutManagerHandle::run_callback_if_expired | ( | internal::TimeoutManagerHandleKey | key | ) |
Check if timeout is expired and if yes, call it.
| key | Key type to prevent users from calling this function. |