From 50118c31279e5ef4882c8d8deda0ee17378618aa Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Sat, 23 Nov 2019 00:05:07 -0500 Subject: [PATCH] Change ILinkLayer::ScheduleTick to use new timer --- llarp/link/server.cpp | 11 +++++++---- llarp/link/server.hpp | 11 ++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/llarp/link/server.cpp b/llarp/link/server.cpp index 8f5311e0c..fcdf78fca 100644 --- a/llarp/link/server.cpp +++ b/llarp/link/server.cpp @@ -7,6 +7,8 @@ #include #include +constexpr uint64_t LINK_LAYER_TICK_INTERVAL = 100; + namespace llarp { static constexpr size_t MaxSessionsPerKey = 16; @@ -289,7 +291,7 @@ namespace llarp { m_Worker = worker; m_Logic = l; - ScheduleTick(100); + ScheduleTick(LINK_LAYER_TICK_INTERVAL); return true; } @@ -450,17 +452,18 @@ namespace llarp } void - ILinkLayer::OnTick(uint64_t interval) + ILinkLayer::OnTick() { auto now = Now(); Tick(now); - ScheduleTick(interval); + ScheduleTick(LINK_LAYER_TICK_INTERVAL); } void ILinkLayer::ScheduleTick(uint64_t interval) { - tick_id = m_Logic->call_later({interval, this, &ILinkLayer::on_timer_tick}); + tick_id = m_Logic->call_later(interval, + std::bind(&ILinkLayer::on_timer_tick, this)); } void diff --git a/llarp/link/server.hpp b/llarp/link/server.hpp index f8bd0ab87..eeed5fd87 100644 --- a/llarp/link/server.hpp +++ b/llarp/link/server.hpp @@ -207,17 +207,14 @@ namespace llarp } private: - static void - on_timer_tick(void* user, uint64_t orig, uint64_t left) + void + on_timer_tick() { - // timer cancelled - if(left) - return; - static_cast< ILinkLayer* >(user)->OnTick(orig); + OnTick(); } void - OnTick(uint64_t interval); + OnTick(); void ScheduleTick(uint64_t interval);