ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
Classes | Public Member Functions | List of all members
rclcpp::ClockWaiter Class Reference

#include <rclcpp/clock.hpp>

Classes

class  ClockWaiterImpl
 

Public Member Functions

RCLCPP_PUBLIC ClockWaiter (const rclcpp::Clock::SharedPtr &clock)
 
RCLCPP_PUBLIC bool wait_until (std::unique_lock< std::mutex > &lock, const rclcpp::Time &abs_time, const std::function< bool()> &pred)
 
RCLCPP_PUBLIC void notify_one ()
 

Detailed Description

A synchronization primitive, equal to std::conditional_variable, that works with the rclcpp::Clock.

For more information on the API see https://en.cppreference.com/w/cpp/thread/condition_variable.

Note, this class does not handle shutdowns, if you want to haven them handles as well, use ClockConditionalVariable.

Definition at line 284 of file clock.hpp.

Member Function Documentation

◆ notify_one()

void rclcpp::ClockWaiter::notify_one ( )

Notify the blocked thread, that it should reevaluate the wakeup condition. The given pred function in wait_until will be reevaluated and wait_until will return if it evaluates to true.

Definition at line 515 of file clock.cpp.

◆ wait_until()

bool rclcpp::ClockWaiter::wait_until ( std::unique_lock< std::mutex > &  lock,
const rclcpp::Time abs_time,
const std::function< bool()> &  pred 
)

Calling this function will block the current thread, until abs_time is reached, or pred returns true.

Parameters
lockA locked lock. The lock must be locked at call time, or this method will throw. The lock will be atomically released and this thread will blocked.
abs_timeThe time until which this thread shall be blocked.
predmay be called in cased of spurious wakeups, but must be called every time notify_one() was called. During the call to pred, the given lock will be locked. This method will return, if pred returns true.

Definition at line 507 of file clock.cpp.


The documentation for this class was generated from the following files: