summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/OSSupport/CriticalSection.cpp13
-rw-r--r--source/OSSupport/CriticalSection.h2
2 files changed, 10 insertions, 5 deletions
diff --git a/source/OSSupport/CriticalSection.cpp b/source/OSSupport/CriticalSection.cpp
index d83d7af02..bda97e3a1 100644
--- a/source/OSSupport/CriticalSection.cpp
+++ b/source/OSSupport/CriticalSection.cpp
@@ -22,6 +22,10 @@ cCriticalSection::cCriticalSection()
LOGERROR("Could not initialize Critical Section!");
}
#endif
+
+ #ifdef _DEBUG
+ m_IsLocked = 0;
+ #endif // _DEBUG
}
@@ -54,7 +58,7 @@ void cCriticalSection::Lock()
#endif
#ifdef _DEBUG
- m_IsLocked = true;
+ m_IsLocked += 1;
m_OwningThreadID = cIsThread::GetCurrentID();
#endif // _DEBUG
}
@@ -66,7 +70,8 @@ void cCriticalSection::Lock()
void cCriticalSection::Unlock()
{
#ifdef _DEBUG
- m_IsLocked = false;
+ ASSERT(m_IsLocked > 0);
+ m_IsLocked -= 1;
#endif // _DEBUG
#ifdef _WIN32
@@ -83,7 +88,7 @@ void cCriticalSection::Unlock()
#ifdef _DEBUG
bool cCriticalSection::IsLocked(void)
{
- return m_IsLocked;
+ return (m_IsLocked > 0);
}
@@ -92,7 +97,7 @@ bool cCriticalSection::IsLocked(void)
bool cCriticalSection::IsLockedByCurrentThread(void)
{
- return (m_IsLocked && (m_OwningThreadID == cIsThread::GetCurrentID()));
+ return ((m_IsLocked > 0) && (m_OwningThreadID == cIsThread::GetCurrentID()));
}
#endif // _DEBUG
diff --git a/source/OSSupport/CriticalSection.h b/source/OSSupport/CriticalSection.h
index c7607ee70..1bfe81439 100644
--- a/source/OSSupport/CriticalSection.h
+++ b/source/OSSupport/CriticalSection.h
@@ -21,7 +21,7 @@ public:
private:
#ifdef _DEBUG
- bool m_IsLocked;
+ int m_IsLocked; // Number of times this CS is locked
unsigned long m_OwningThreadID;
#endif // _DEBUG