Skip to content

Commit a39118f

Browse files
authored
Merge pull request #143 from ruudvd/develop
Changed system to steady clock
2 parents 458bcb0 + 9f397ef commit a39118f

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/tools/helpers/Timer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Timer::Timer(ITimerPool& pool, const char* name)
3030
m_name(name),
3131
m_single_shot(false),
3232
m_interval(std::chrono::milliseconds(0)),
33-
m_wake_up_time_point(std::chrono::time_point<std::chrono::system_clock>::min()),
33+
m_wake_up_time_point(std::chrono::time_point<std::chrono::steady_clock>::min()),
3434
m_started(false),
3535
m_callback()
3636
{
@@ -57,7 +57,7 @@ bool Timer::start(std::chrono::milliseconds interval, bool single_shot)
5757
// Configure timer
5858
m_interval = interval;
5959
m_single_shot = single_shot;
60-
m_wake_up_time_point = std::chrono::system_clock::now() + m_interval;
60+
m_wake_up_time_point = std::chrono::steady_clock::now() + m_interval;
6161

6262
// Add timer to the list
6363
m_pool.addTimer(this);
@@ -92,7 +92,7 @@ bool Timer::restart(std::chrono::milliseconds interval, bool single_shot)
9292
// Configure timer
9393
m_interval = interval;
9494
m_single_shot = single_shot;
95-
m_wake_up_time_point = std::chrono::system_clock::now() + m_interval;
95+
m_wake_up_time_point = std::chrono::steady_clock::now() + m_interval;
9696

9797
// Add timer to the list
9898
m_pool.addTimer(this);

src/tools/helpers/Timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Timer
113113
/** @brief Wake uo interval */
114114
std::chrono::milliseconds m_interval;
115115
/** @brief Next wakeup time point */
116-
std::chrono::time_point<std::chrono::system_clock> m_wake_up_time_point;
116+
std::chrono::time_point<std::chrono::steady_clock> m_wake_up_time_point;
117117
/** @brief Indicate if the timer is started */
118118
bool m_started;
119119
/** @brief Callback */

src/tools/helpers/TimerPool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TimerPool::TimerPool()
3030
m_update_wakeup_time(false),
3131
m_wakeup_mutex(),
3232
m_wakeup_cond(),
33-
m_wake_up_time_point(std::chrono::system_clock::now() + std::chrono::hours(2400u)),
33+
m_wake_up_time_point(std::chrono::steady_clock::now() + std::chrono::hours(2400u)),
3434
m_thread(std::bind(&TimerPool::threadLoop, this)),
3535
m_timers(),
3636
m_active_timers()
@@ -122,7 +122,7 @@ void TimerPool::computeNextWakeupTimepoint()
122122
if (m_active_timers.empty())
123123
{
124124
// Next wakeup in 100days
125-
m_wake_up_time_point = std::chrono::system_clock::now() + std::chrono::hours(2400u);
125+
m_wake_up_time_point = std::chrono::steady_clock::now() + std::chrono::hours(2400u);
126126
}
127127
else
128128
{

src/tools/helpers/TimerPool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class TimerPool : public ITimerPool
6262
/** @brief Wakeup condition */
6363
std::condition_variable m_wakeup_cond;
6464
/** @brief Next wakeup time point */
65-
std::chrono::time_point<std::chrono::system_clock> m_wake_up_time_point;
65+
std::chrono::time_point<std::chrono::steady_clock> m_wake_up_time_point;
6666
/** @brief Timers thread */
6767
std::thread m_thread;
6868
/** @brief List of registered timers */

0 commit comments

Comments
 (0)