diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-12-14 23:36:12 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-12-14 23:36:12 +0100 |
commit | 15fe5a1d41acc50dd2111309a352575a1edacf1c (patch) | |
tree | 8ae9252957c83dce0b1034e3864eb6335b53c1b5 /source | |
parent | Fixed warnings in Player.cpp (diff) | |
download | cuberite-15fe5a1d41acc50dd2111309a352575a1edacf1c.tar cuberite-15fe5a1d41acc50dd2111309a352575a1edacf1c.tar.gz cuberite-15fe5a1d41acc50dd2111309a352575a1edacf1c.tar.bz2 cuberite-15fe5a1d41acc50dd2111309a352575a1edacf1c.tar.lz cuberite-15fe5a1d41acc50dd2111309a352575a1edacf1c.tar.xz cuberite-15fe5a1d41acc50dd2111309a352575a1edacf1c.tar.zst cuberite-15fe5a1d41acc50dd2111309a352575a1edacf1c.zip |
Diffstat (limited to '')
-rw-r--r-- | source/OSSupport/CriticalSection.cpp | 13 | ||||
-rw-r--r-- | source/OSSupport/CriticalSection.h | 2 |
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 |