Signed-off-by: falkTX <falktx@falktx.com>tags/v2.1-rc1
| @@ -81,7 +81,11 @@ static uint32 water_millisecondsSinceStartup() noexcept | |||||
| return (uint32) timeGetTime(); | return (uint32) timeGetTime(); | ||||
| #else | #else | ||||
| timespec t; | timespec t; | ||||
| # ifdef CLOCK_MONOTONIC_RAW | |||||
| clock_gettime (CLOCK_MONOTONIC_RAW, &t); | |||||
| # else | |||||
| clock_gettime (CLOCK_MONOTONIC, &t); | clock_gettime (CLOCK_MONOTONIC, &t); | ||||
| # endif | |||||
| return (uint32) (t.tv_sec * 1000 + t.tv_nsec / 1000000); | return (uint32) (t.tv_sec * 1000 + t.tv_nsec / 1000000); | ||||
| #endif | #endif | ||||
| @@ -146,10 +150,4 @@ uint32 Time::getMillisecondCounter() noexcept | |||||
| return now; | return now; | ||||
| } | } | ||||
| uint32 Time::getApproximateMillisecondCounter() noexcept | |||||
| { | |||||
| const uint32 t = TimeHelpers::lastMSCounterValue.get(); | |||||
| return t == 0 ? getMillisecondCounter() : t; | |||||
| } | |||||
| } | } | ||||
| @@ -103,22 +103,9 @@ public: | |||||
| Being a 32-bit return value, it will of course wrap back to 0 after 2^32 seconds of | Being a 32-bit return value, it will of course wrap back to 0 after 2^32 seconds of | ||||
| uptime, so be careful to take that into account. If you need a 64-bit time, you can | uptime, so be careful to take that into account. If you need a 64-bit time, you can | ||||
| use currentTimeMillis() instead. | use currentTimeMillis() instead. | ||||
| @see getApproximateMillisecondCounter | |||||
| */ | */ | ||||
| static uint32 getMillisecondCounter() noexcept; | static uint32 getMillisecondCounter() noexcept; | ||||
| /** Less-accurate but faster version of getMillisecondCounter(). | |||||
| This will return the last value that getMillisecondCounter() returned, so doesn't | |||||
| need to make a system call, but is less accurate - it shouldn't be more than | |||||
| 100ms away from the correct time, though, so is still accurate enough for a | |||||
| lot of purposes. | |||||
| @see getMillisecondCounter | |||||
| */ | |||||
| static uint32 getApproximateMillisecondCounter() noexcept; | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| int64 millisSinceEpoch; | int64 millisSinceEpoch; | ||||
| @@ -146,7 +146,7 @@ String StringPool::getPooledString (const String& newString) | |||||
| void StringPool::garbageCollectIfNeeded() | void StringPool::garbageCollectIfNeeded() | ||||
| { | { | ||||
| if (strings.size() > minNumberOfStringsForGarbageCollection | if (strings.size() > minNumberOfStringsForGarbageCollection | ||||
| && Time::getApproximateMillisecondCounter() > lastGarbageCollectionTime + garbageCollectionInterval) | |||||
| && Time::getMillisecondCounter() > lastGarbageCollectionTime + garbageCollectionInterval) | |||||
| garbageCollect(); | garbageCollect(); | ||||
| } | } | ||||
| @@ -158,7 +158,7 @@ void StringPool::garbageCollect() | |||||
| if (strings.getReference(i).getReferenceCount() == 1) | if (strings.getReference(i).getReferenceCount() == 1) | ||||
| strings.remove (i); | strings.remove (i); | ||||
| lastGarbageCollectionTime = Time::getApproximateMillisecondCounter(); | |||||
| lastGarbageCollectionTime = Time::getMillisecondCounter(); | |||||
| } | } | ||||
| StringPool& StringPool::getGlobalPool() noexcept | StringPool& StringPool::getGlobalPool() noexcept | ||||