diff --git a/Source/Engine/Content/Cache/AssetsCache.cpp b/Source/Engine/Content/Cache/AssetsCache.cpp
index e9ce23e1a..188a52583 100644
--- a/Source/Engine/Content/Cache/AssetsCache.cpp
+++ b/Source/Engine/Content/Cache/AssetsCache.cpp
@@ -141,7 +141,7 @@ void AssetsCache::Init()
}
stopwatch.Stop();
- LOG(Info, "Asset Cache loaded {0} entries in {1} ms ({2} rejected)", _registry.Count(), stopwatch.GetMilliseconds(), rejectedCount);
+ LOG(Info, "Asset Cache loaded {0} entries in {1}ms ({2} rejected)", _registry.Count(), stopwatch.GetMilliseconds(), rejectedCount);
}
bool AssetsCache::Save()
diff --git a/Source/Engine/Content/Storage/AssetHeader.h b/Source/Engine/Content/Storage/AssetHeader.h
index 3c37ce35e..5c4031993 100644
--- a/Source/Engine/Content/Storage/AssetHeader.h
+++ b/Source/Engine/Content/Storage/AssetHeader.h
@@ -6,6 +6,7 @@
#include "Engine/Core/Types/Pair.h"
#include "Engine/Core/Types/String.h"
#if USE_EDITOR
+#include "Engine/Core/Types/DateTime.h"
#include "Engine/Core/Collections/Array.h"
#endif
#include "FlaxChunk.h"
diff --git a/Source/Engine/Content/Storage/FlaxChunk.h b/Source/Engine/Content/Storage/FlaxChunk.h
index 710540a02..df6a8974a 100644
--- a/Source/Engine/Content/Storage/FlaxChunk.h
+++ b/Source/Engine/Content/Storage/FlaxChunk.h
@@ -78,9 +78,9 @@ public:
FlaxChunkFlags Flags = FlaxChunkFlags::None;
///
- /// The last usage time (atomic, ticks of DateTime in UTC).
+ /// The last usage time.
///
- int64 LastAccessTime = 0;
+ double LastAccessTime = 0.0;
///
/// The chunk data.
diff --git a/Source/Engine/Content/Storage/FlaxStorage.cpp b/Source/Engine/Content/Storage/FlaxStorage.cpp
index df99418bb..a24e01884 100644
--- a/Source/Engine/Content/Storage/FlaxStorage.cpp
+++ b/Source/Engine/Content/Storage/FlaxStorage.cpp
@@ -27,7 +27,7 @@ String AssetHeader::ToString() const
void FlaxChunk::RegisterUsage()
{
- Platform::AtomicStore(&LastAccessTime, DateTime::NowUTC().Ticks);
+ LastAccessTime = Platform::GetTimeSeconds();
}
const int32 FlaxStorage::MagicCode = 1180124739;
@@ -229,7 +229,9 @@ uint32 FlaxStorage::GetRefCount() const
bool FlaxStorage::ShouldDispose() const
{
- return Platform::AtomicRead((int64*)&_refCount) == 0 && Platform::AtomicRead((int64*)&_chunksLock) == 0 && DateTime::NowUTC() - _lastRefLostTime >= TimeSpan::FromMilliseconds(500);
+ return Platform::AtomicRead((int64*)&_refCount) == 0 &&
+ Platform::AtomicRead((int64*)&_chunksLock) == 0 &&
+ Platform::GetTimeSeconds() - _lastRefLostTime >= 0.5; // TTL in seconds
}
uint32 FlaxStorage::GetMemoryUsage() const
@@ -1363,12 +1365,13 @@ void FlaxStorage::Tick()
if (Platform::AtomicRead(&_chunksLock) != 0)
return;
- const auto now = DateTime::NowUTC();
+ const double now = Platform::GetTimeSeconds();
bool wasAnyUsed = false;
+ const float unusedDataChunksLifetime = ContentStorageManager::UnusedDataChunksLifetime.GetTotalSeconds();
for (int32 i = 0; i < _chunks.Count(); i++)
{
- auto chunk = _chunks[i];
- const bool wasUsed = (now - DateTime(Platform::AtomicRead(&chunk->LastAccessTime))) < ContentStorageManager::UnusedDataChunksLifetime;
+ auto chunk = _chunks.Get()[i];
+ const bool wasUsed = (now - chunk->LastAccessTime) < unusedDataChunksLifetime;
if (!wasUsed && chunk->IsLoaded())
{
chunk->Unload();
diff --git a/Source/Engine/Content/Storage/FlaxStorage.h b/Source/Engine/Content/Storage/FlaxStorage.h
index 77c912c5a..23fb7a35f 100644
--- a/Source/Engine/Content/Storage/FlaxStorage.h
+++ b/Source/Engine/Content/Storage/FlaxStorage.h
@@ -5,7 +5,6 @@
#include "Engine/Core/Object.h"
#include "Engine/Core/Delegate.h"
#include "Engine/Core/Types/String.h"
-#include "Engine/Core/Types/DateTime.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Platform/CriticalSection.h"
#include "Engine/Serialization/FileReadStream.h"
@@ -90,7 +89,7 @@ protected:
// State
int64 _refCount;
int64 _chunksLock;
- DateTime _lastRefLostTime;
+ double _lastRefLostTime;
CriticalSection _loadLocker;
// Storage
@@ -115,7 +114,7 @@ private:
Platform::InterlockedDecrement(&_refCount);
if (Platform::AtomicRead(&_refCount) == 0)
{
- _lastRefLostTime = DateTime::NowUTC();
+ _lastRefLostTime = Platform::GetTimeSeconds();
}
}
diff --git a/Source/Engine/Core/ObjectsRemovalService.cpp b/Source/Engine/Core/ObjectsRemovalService.cpp
index a185ce8b3..454ce7d43 100644
--- a/Source/Engine/Core/ObjectsRemovalService.cpp
+++ b/Source/Engine/Core/ObjectsRemovalService.cpp
@@ -17,7 +17,7 @@ Span Utilities::Private::HertzSizes(HertzSizesData, ARRAY_COUNT(Her
namespace
{
CriticalSection PoolLocker;
- DateTime LastUpdate;
+ double LastUpdate;
float LastUpdateGameTime;
Dictionary