summaryrefslogtreecommitdiffstats
path: root/source/cCriticalSection.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
commit4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c (patch)
treefebea3ecd89c0d4aa83924e430bf11366d754733 /source/cCriticalSection.h
parentNew makefile with automatic *.cpp sourcefile import, automatic header file dependencies and switchable debug / release configuration. gnumake-specific :( (diff)
downloadcuberite-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.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/source/cCriticalSection.h b/source/cCriticalSection.h
index 86c196255..8faa04765 100644
--- a/source/cCriticalSection.h
+++ b/source/cCriticalSection.h
@@ -1,18 +1,27 @@
+
#pragma once
+
+
+
+
class cCriticalSection
{
public:
- cCriticalSection();
+ cCriticalSection(void);
~cCriticalSection();
- void Lock();
- void Unlock();
+ void Lock(void);
+ void Unlock(void);
+
private:
- void* m_CriticalSectionPtr; // Pointer to a CRITICAL_SECTION object
-#ifndef _WIN32
- void* m_Attributes;
-#endif
+
+ #ifdef _WIN32
+ CRITICAL_SECTION m_CriticalSection;
+ #else // _WIN32
+ void* m_CriticalSectionPtr; // Pointer to a CRITICAL_SECTION object
+ void* m_Attributes;
+ #endif // else _WIN32
};
@@ -23,10 +32,10 @@ class cCSLock
{
cCriticalSection * m_CS;
- #ifdef _DEBUG
// Unlike a cCriticalSection, this object should be used from a single thread, therefore access to m_IsLocked is not threadsafe
+ // In Windows, it is an error to call cCriticalSection::Unlock() multiple times if the lock is not held,
+ // therefore we need to check this value whether we are locked or not.
bool m_IsLocked;
- #endif // _DEBUG
public:
cCSLock(cCriticalSection * a_CS);