Skip to content

Commit

Permalink
use wait_for(), remove TimerManagerTraits
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Feb 6, 2020
1 parent 7d470f3 commit 2a67cf6
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions clients/roscpp/include/ros/timer_manager.h
Expand Up @@ -46,22 +46,6 @@
namespace ros
{

namespace {
template<class T>
class TimerManagerTraits
{
public:
typedef boost::chrono::system_clock::time_point time_point;
};

template<>
class TimerManagerTraits<SteadyTime>
{
public:
typedef boost::chrono::steady_clock::time_point time_point;
};
}

template<class T, class D, class E>
class TimerManager
{
Expand Down Expand Up @@ -592,8 +576,8 @@ void TimerManager<T, D, E>::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<T>::time_point end_tp(boost::chrono::nanoseconds(sleep_end.toNSec()));
timers_cond_.wait_until(lock, end_tp);
int64_t remaining_time = std::max<int64_t>((sleep_end - current).toSec() * 1000.0f, 1);
timers_cond_.wait_for(lock, boost::chrono::milliseconds(remaining_time));
}
}

Expand Down

0 comments on commit 2a67cf6

Please sign in to comment.