Add error log when adding/removign actors during rendering or when ConcurrentSystemLocker deadlocks
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
#include "ConcurrentSystemLocker.h"
|
||||
#include "Engine/Platform/Platform.h"
|
||||
#if !BUILD_RELEASE
|
||||
#include "Engine/Core/Log.h"
|
||||
#endif
|
||||
|
||||
ConcurrentSystemLocker::ConcurrentSystemLocker()
|
||||
{
|
||||
@@ -12,7 +15,25 @@ void ConcurrentSystemLocker::Begin(bool write, bool exclusively)
|
||||
{
|
||||
volatile int64* thisCounter = &_counters[write];
|
||||
volatile int64* otherCounter = &_counters[!write];
|
||||
|
||||
#if !BUILD_RELEASE
|
||||
int32 retries = 0;
|
||||
double startTime = Platform::GetTimeSeconds();
|
||||
#endif
|
||||
RETRY:
|
||||
#if !BUILD_RELEASE
|
||||
retries++;
|
||||
if (retries > 1000)
|
||||
{
|
||||
double endTime = Platform::GetTimeSeconds();
|
||||
if (endTime - startTime > 0.5f)
|
||||
{
|
||||
LOG(Error, "Deadlock detected in ConcurrentSystemLocker! Thread 0x{0:x} waits for {1} ms...", Platform::GetCurrentThreadID(), (int32)((endTime - startTime) * 1000.0));
|
||||
retries = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check if we can enter (cannot read while someone else is writing and vice versa)
|
||||
if (Platform::AtomicRead(otherCounter) != 0)
|
||||
{
|
||||
@@ -47,3 +68,8 @@ void ConcurrentSystemLocker::End(bool write)
|
||||
// Mark that we left this section
|
||||
Platform::InterlockedDecrement(&_counters[write]);
|
||||
}
|
||||
|
||||
bool ConcurrentSystemLocker::HasLock(bool write) const
|
||||
{
|
||||
return Platform::AtomicRead(&_counters[write]) != 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user