Minor fix for Web no threads

This commit is contained in:
Wojtek Figat
2026-03-06 11:10:13 +01:00
parent 94789712e8
commit f0873411df
2 changed files with 3 additions and 0 deletions

View File

@@ -91,6 +91,7 @@ public:
/// Flag set to indicate that chunk is during loading (atomic access to sync multiple reading threads).
/// </summary>
int64 IsLoading = 0;
/// <summary>
/// The chunk data.
/// </summary>

View File

@@ -714,10 +714,12 @@ bool FlaxStorage::LoadAssetChunk(FlaxChunk* chunk)
ASSERT(IsLoaded());
ASSERT(chunk != nullptr && _chunks.Contains(chunk));
#if PLATFORM_THREADS_LIMIT > 1
// Protect against loading the same chunk from multiple threads at once
while (Platform::InterlockedCompareExchange(&chunk->IsLoading, 1, 0) != 0)
Platform::Sleep(1);
SCOPE_EXIT{ Platform::AtomicStore(&chunk->IsLoading, 0); };
#endif
if (chunk->IsLoaded())
return false;