diff options
| author | Carbenium <carbenium@outlook.com> | 2020-07-29 00:00:51 +0200 |
|---|---|---|
| committer | Peter Keresztes Schmidt <carbenium@outlook.com> | 2020-08-01 12:43:55 +0200 |
| commit | e55516348dbabaa8c9d559426315f3f70967acaa (patch) | |
| tree | cb2835ba80ef014b03b909b1af306b48daccb165 /src/common/Utilities/Timer.h | |
| parent | 9b806c6b5d9e83f8614523317a44742954f97744 (diff) | |
Core/Common: Add a std::chrono interface to TimeTrackerSmall
New methods:
TimeTrackerSmall(Milliseconds expiry);
void Update(Milliseconds diff);
void Reset(Milliseconds expiry)
Milliseconds GetExpiry() const
Removed methods:
int32 GetExpiry() const
Also add basic unit tests.
Core/Scripts: Use std::chrono interface of TimeTrackerSmall
Diffstat (limited to 'src/common/Utilities/Timer.h')
| -rw-r--r-- | src/common/Utilities/Timer.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/common/Utilities/Timer.h b/src/common/Utilities/Timer.h index 4abd6cc8ca1..8acd5cbdc11 100644 --- a/src/common/Utilities/Timer.h +++ b/src/common/Utilities/Timer.h @@ -19,7 +19,7 @@ #define TRINITY_TIMER_H #include "Define.h" -#include <chrono> +#include "Duration.h" inline std::chrono::steady_clock::time_point GetApplicationStartTime() { @@ -155,11 +155,18 @@ public: { } + TimeTrackerSmall(Milliseconds expiry) : i_expiryTime(expiry.count()) { } + void Update(int32 diff) { i_expiryTime -= diff; } + void Update(Milliseconds diff) + { + Update(diff.count()); + } + bool Passed() const { return i_expiryTime <= 0; @@ -170,9 +177,14 @@ public: i_expiryTime = interval; } - int32 GetExpiry() const + void Reset(Milliseconds expiry) { - return i_expiryTime; + Reset(expiry.count()); + } + + Milliseconds GetExpiry() const + { + return Milliseconds(i_expiryTime); } private: |
