mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
mrs_lib::TimeoutManagerHandle Class Reference

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.

Detailed Description

Handle to a registered timeout, that unregisters it on destruction.

Constructor & Destructor Documentation

◆ TimeoutManagerHandle()

mrs_lib::TimeoutManagerHandle::TimeoutManagerHandle ( internal::TimeoutManagerHandleKey key,
TimeoutManagerRegisterOptions options,
std::shared_ptr< rclcpp::node_interfaces::NodeClockInterface > clock_interface )
explicit

Construct the handle.

Parameters
keyKey type to prevent users from calling this function.
optionsOptions to configure the timeout.
clock_interfaceClock interface to use for obtaining current time.
Note
This function is for internal use and should not be called from user code.

Member Function Documentation

◆ get_last_reset()

rclcpp::Time mrs_lib::TimeoutManagerHandle::get_last_reset ( ) const
nodiscard

Get time of last call to reset.

Returns
Last time the reset was called.

◆ is_started()

bool mrs_lib::TimeoutManagerHandle::is_started ( ) const
nodiscard

Check if the timeout is started.

Returns
true if it is started, false otherwise.

◆ pause()

void mrs_lib::TimeoutManagerHandle::pause ( )

Stop the timeout.

After this call, new timeout callbacks won't be called until a call to start.

◆ reset_timeout()

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.

◆ run_callback_if_expired()

void mrs_lib::TimeoutManagerHandle::run_callback_if_expired ( internal::TimeoutManagerHandleKey key)

Check if timeout is expired and if yes, call it.

Parameters
keyKey type to prevent users from calling this function.
Note
This function is for internal use and should not be called from user code.

The documentation for this class was generated from the following files:
  • /home/runner/work/mrs_lib/mrs_lib/include/mrs_lib/timeout_manager.hpp
  • /home/runner/work/mrs_lib/mrs_lib/src/timeout_manager/timeout_manager2.cpp