diff --git a/Source/Engine/Content/Storage/FlaxChunk.h b/Source/Engine/Content/Storage/FlaxChunk.h index 1d3bdce1a..4b33e47a2 100644 --- a/Source/Engine/Content/Storage/FlaxChunk.h +++ b/Source/Engine/Content/Storage/FlaxChunk.h @@ -91,6 +91,7 @@ public: /// Flag set to indicate that chunk is during loading (atomic access to sync multiple reading threads). /// int64 IsLoading = 0; + /// /// The chunk data. /// diff --git a/Source/Engine/Content/Storage/FlaxStorage.cpp b/Source/Engine/Content/Storage/FlaxStorage.cpp index 362257369..2fb670e94 100644 --- a/Source/Engine/Content/Storage/FlaxStorage.cpp +++ b/Source/Engine/Content/Storage/FlaxStorage.cpp @@ -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;