1
0

Fixed cCriticalSection's debugging functions

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1072 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-12-14 22:36:12 +00:00
parent 50e87ac978
commit 15fe5a1d41
2 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -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