Add UnusedStorageLifetime for asset file TTL

#3931
This commit is contained in:
Wojtek Figat
2026-03-25 21:30:07 +01:00
parent 9d0e4e9768
commit a84109df2c
3 changed files with 11 additions and 5 deletions

View File

@@ -46,6 +46,7 @@ namespace
ContentStorageService ContentStorageServiceInstance;
TimeSpan ContentStorageManager::UnusedStorageLifetime = TimeSpan::FromSeconds(0.5f);
TimeSpan ContentStorageManager::UnusedDataChunksLifetime = TimeSpan::FromSeconds(10);
FlaxStorageReference ContentStorageManager::GetStorage(const StringView& path, bool loadIt)

View File

@@ -15,7 +15,12 @@ class FLAXENGINE_API ContentStorageManager
{
public:
/// <summary>
/// Auto-release timeout for unused asset chunks.
/// Auto-release timeout for unused asset files.
/// </summary>
static TimeSpan UnusedStorageLifetime;
/// <summary>
/// Auto-release timeout for unused asset data chunks.
/// </summary>
static TimeSpan UnusedDataChunksLifetime;

View File

@@ -286,14 +286,14 @@ FlaxStorage::LockData FlaxStorage::LockSafe()
uint32 FlaxStorage::GetRefCount() const
{
return (uint32)Platform::AtomicRead((int64*)&_refCount);
return (uint32)Platform::AtomicRead(&_refCount);
}
bool FlaxStorage::ShouldDispose() const
{
return Platform::AtomicRead((int64*)&_refCount) == 0 &&
Platform::AtomicRead((int64*)&_chunksLock) == 0 &&
Platform::GetTimeSeconds() - _lastRefLostTime >= 0.5; // TTL in seconds
return Platform::AtomicRead(&_refCount) == 0 &&
Platform::AtomicRead(&_chunksLock) == 0 &&
Platform::GetTimeSeconds() - _lastRefLostTime >= ContentStorageManager::UnusedStorageLifetime.GetTotalSeconds();
}
uint32 FlaxStorage::GetMemoryUsage() const