From 2a67cf6780c32fef3af96fac9da405f4e6eb0298 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Wed, 5 Feb 2020 16:30:00 -0800 Subject: [PATCH] use wait_for(), remove TimerManagerTraits --- clients/roscpp/include/ros/timer_manager.h | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/clients/roscpp/include/ros/timer_manager.h b/clients/roscpp/include/ros/timer_manager.h index ecf7088bdd..e574d0ea6c 100644 --- a/clients/roscpp/include/ros/timer_manager.h +++ b/clients/roscpp/include/ros/timer_manager.h @@ -46,22 +46,6 @@ namespace ros { -namespace { - template - class TimerManagerTraits - { - public: - typedef boost::chrono::system_clock::time_point time_point; - }; - - template<> - class TimerManagerTraits - { - public: - typedef boost::chrono::steady_clock::time_point time_point; - }; -} - template class TimerManager { @@ -592,8 +576,8 @@ void TimerManager::threadFunc() { // On system time we can simply sleep for the rest of the wait time, since anything else requiring processing will // signal the condition variable - typename TimerManagerTraits::time_point end_tp(boost::chrono::nanoseconds(sleep_end.toNSec())); - timers_cond_.wait_until(lock, end_tp); + int64_t remaining_time = std::max((sleep_end - current).toSec() * 1000.0f, 1); + timers_cond_.wait_for(lock, boost::chrono::milliseconds(remaining_time)); } }