From: Mikko Rasa Date: Fri, 25 Dec 2015 10:16:47 +0000 (+0200) Subject: Split Timer::tick into two overloads X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=108f2e7de1c2427e39cdf55efbcd0ca3914e451a;p=libs%2Fcore.git Split Timer::tick into two overloads This is in line with other similar interfaces, such as Poller and Semaphore. The old function still exists but is deprecated. --- diff --git a/source/time/timer.cpp b/source/time/timer.cpp index 7c9567e..be1d1ed 100644 --- a/source/time/timer.cpp +++ b/source/time/timer.cpp @@ -56,6 +56,28 @@ void Timer::cancel(Slot &slot) void Timer::tick(bool block) { + if(block) + tick(); + else + tick(zero); +} + +void Timer::tick() +{ + do_tick(-sec); +} + +void Timer::tick(const TimeDelta &timeout) +{ + do_tick(timeout); +} + +void Timer::do_tick(const TimeDelta &timeout) +{ + TimeStamp deadline; + if(timeout>=zero) + deadline = now()+timeout; + Slot *next = 0; { MutexLock l(mutex); @@ -71,12 +93,14 @@ void Timer::tick(bool block) break; } - if(block) + if(timeout && (!deadline || t