aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/Timer.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/shared/Timer.h b/src/shared/Timer.h
index 82f5be161d9..46bba5475bc 100644
--- a/src/shared/Timer.h
+++ b/src/shared/Timer.h
@@ -95,5 +95,28 @@ struct TimeTrackerSmall
int32 i_expiryTime;
};
+struct PeriodicTimer
+{
+ PeriodicTimer(int32 period, int32 start_time) :
+ i_expireTime(start_time), i_period(period) {}
+
+ bool Update(const uint32 &diff)
+ {
+ if((i_expireTime -= diff) > 0)
+ return false;
+
+ i_expireTime += i_period > diff ? i_period : diff;
+ return true;
+ }
+
+ void SetPeriodic(int32 period, int32 start_time)
+ {
+ i_expireTime=start_time, i_period=period;
+ }
+
+ int32 i_period;
+ int32 i_expireTime;
+};
+
#endif