Skip to content

Commit 22c1c44

Browse files
committed
Using steady timer.
1 parent d5c979b commit 22c1c44

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

source/base/threading/asio_event_dispatcher.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const size_t kReservedSizeForEvents = 20;
4545
AsioEventDispatcher::AsioEventDispatcher(QObject* parent)
4646
: QAbstractEventDispatcher(parent),
4747
work_guard_(asio::make_work_guard(io_context_)),
48-
high_resolution_timer_(io_context_)
48+
timer_(io_context_)
4949
{
5050
LOG(LS_INFO) << "Ctor";
5151

@@ -315,8 +315,8 @@ void AsioEventDispatcher::asyncWaitForNextTimer()
315315
const int next_timer_id = next_expire_timer->second.timer_id;
316316

317317
// Start waiting for the timer.
318-
high_resolution_timer_.expires_at(next_expire_timer->second.expire_time);
319-
high_resolution_timer_.async_wait([this, next_timer_id](const std::error_code& error_code)
318+
timer_.expires_at(next_expire_timer->second.expire_time);
319+
timer_.async_wait([this, next_timer_id](const std::error_code& error_code)
320320
{
321321
if (error_code || interrupted_.load(std::memory_order_relaxed))
322322
return;

source/base/threading/asio_event_dispatcher.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <QAbstractEventDispatcher>
2525

2626
#include <asio/io_context.hpp>
27-
#include <asio/high_resolution_timer.hpp>
27+
#include <asio/steady_timer.hpp>
2828

2929
#include <atomic>
3030
#include <unordered_map>
@@ -64,7 +64,7 @@ class AsioEventDispatcher final : public QAbstractEventDispatcher
6464
asio::io_context& ioContext();
6565

6666
private:
67-
using Clock = std::chrono::high_resolution_clock;
67+
using Clock = std::chrono::steady_clock;
6868
using TimePoint = Clock::time_point;
6969
using Milliseconds = std::chrono::milliseconds;
7070

@@ -97,7 +97,7 @@ class AsioEventDispatcher final : public QAbstractEventDispatcher
9797
asio::executor_work_guard<asio::io_context::executor_type> work_guard_;
9898
std::atomic_bool interrupted_ { false };
9999
std::unordered_map<int, TimerData> timers_;
100-
asio::high_resolution_timer high_resolution_timer_;
100+
asio::steady_timer timer_;
101101

102102
DISALLOW_COPY_AND_ASSIGN(AsioEventDispatcher);
103103
};

0 commit comments

Comments
 (0)