diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-13 22:47:03 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-13 22:47:03 +0100 |
commit | 4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c (patch) | |
tree | febea3ecd89c0d4aa83924e430bf11366d754733 /source/cCriticalSection.cpp | |
parent | New makefile with automatic *.cpp sourcefile import, automatic header file dependencies and switchable debug / release configuration. gnumake-specific :( (diff) | |
download | cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.gz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.bz2 cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.lz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.xz cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.zst cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cCriticalSection.cpp | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/source/cCriticalSection.cpp b/source/cCriticalSection.cpp index d7498aa5f..db182c299 100644 --- a/source/cCriticalSection.cpp +++ b/source/cCriticalSection.cpp @@ -11,8 +11,7 @@ cCriticalSection::cCriticalSection()
{
#ifdef _WIN32
- m_CriticalSectionPtr = new CRITICAL_SECTION;
- InitializeCriticalSection( (CRITICAL_SECTION*)m_CriticalSectionPtr );
+ InitializeCriticalSection( &m_CriticalSection );
#else
m_Attributes = new pthread_mutexattr_t;
pthread_mutexattr_init((pthread_mutexattr_t*)m_Attributes);
@@ -33,8 +32,7 @@ cCriticalSection::cCriticalSection() cCriticalSection::~cCriticalSection()
{
#ifdef _WIN32
- DeleteCriticalSection( (CRITICAL_SECTION*)m_CriticalSectionPtr );
- delete (CRITICAL_SECTION*)m_CriticalSectionPtr;
+ DeleteCriticalSection( &m_CriticalSection );
#else
if( pthread_mutex_destroy( (pthread_mutex_t*)m_CriticalSectionPtr ) != 0 )
{
@@ -53,7 +51,7 @@ cCriticalSection::~cCriticalSection() void cCriticalSection::Lock()
{
#ifdef _WIN32
- EnterCriticalSection( (CRITICAL_SECTION*)m_CriticalSectionPtr );
+ EnterCriticalSection( &m_CriticalSection );
#else
pthread_mutex_lock( (pthread_mutex_t*)m_CriticalSectionPtr );
#endif
@@ -66,7 +64,7 @@ void cCriticalSection::Lock() void cCriticalSection::Unlock()
{
#ifdef _WIN32
- LeaveCriticalSection( (CRITICAL_SECTION*)m_CriticalSectionPtr );
+ LeaveCriticalSection( &m_CriticalSection );
#else
pthread_mutex_unlock( (pthread_mutex_t*)m_CriticalSectionPtr );
#endif
@@ -81,9 +79,7 @@ void cCriticalSection::Unlock() cCSLock::cCSLock(cCriticalSection * a_CS)
: m_CS(a_CS)
- #ifdef _DEBUG
, m_IsLocked(false)
- #endif
{
Lock();
}
@@ -94,9 +90,7 @@ cCSLock::cCSLock(cCriticalSection * a_CS) cCSLock::cCSLock(cCriticalSection & a_CS)
: m_CS(&a_CS)
- #ifdef _DEBUG
, m_IsLocked(false)
- #endif
{
Lock();
}
@@ -107,12 +101,10 @@ cCSLock::cCSLock(cCriticalSection & a_CS) cCSLock::~cCSLock()
{
- #ifdef _DEBUG
if (!m_IsLocked)
{
return;
}
- #endif // _DEBUG
Unlock();
}
@@ -122,11 +114,8 @@ cCSLock::~cCSLock() void cCSLock::Lock(void)
{
- #ifdef _DEBUG
assert(!m_IsLocked);
m_IsLocked = true;
- #endif // _DEBUG
-
m_CS->Lock();
}
@@ -136,11 +125,8 @@ void cCSLock::Lock(void) void cCSLock::Unlock(void)
{
- #ifdef _DEBUG
assert(m_IsLocked);
m_IsLocked = false;
- #endif // _DEBUG
-
m_CS->Unlock();
}
|