summaryrefslogtreecommitdiffstats
path: root/source/cCriticalSection.h
diff options
context:
space:
mode:
authorcedeel@gmail.com <cedeel@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-14 15:06:06 +0200
committercedeel@gmail.com <cedeel@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-14 15:06:06 +0200
commit92c59963f82f81aa3202657e7fdbb2592924ede3 (patch)
treeb7eb2474528a4998fa102e3ec9119b908cee08b4 /source/cCriticalSection.h
parentAdded HOOK_WEATHER_CHANGE. (diff)
downloadcuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.gz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.bz2
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.lz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.xz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.zst
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.zip
Diffstat (limited to '')
-rw-r--r--source/cCriticalSection.h142
1 files changed, 71 insertions, 71 deletions
diff --git a/source/cCriticalSection.h b/source/cCriticalSection.h
index 0a149a95a..a8b475503 100644
--- a/source/cCriticalSection.h
+++ b/source/cCriticalSection.h
@@ -1,71 +1,71 @@
-
-#pragma once
-
-
-
-
-
-class cCriticalSection
-{
-public:
- cCriticalSection(void);
- ~cCriticalSection();
-
- void Lock(void);
- void Unlock(void);
-
-private:
-
- #ifdef _WIN32
- CRITICAL_SECTION m_CriticalSection;
- #else // _WIN32
- void* m_CriticalSectionPtr ALIGN_8; // Pointer to a CRITICAL_SECTION object
- void* m_Attributes ALIGN_8;
- #endif // else _WIN32
-} ALIGN_8;
-
-
-
-
-/// RAII for cCriticalSection - locks the CS on creation, unlocks on destruction
-class cCSLock
-{
- cCriticalSection * m_CS;
-
- // 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;
-
-public:
- cCSLock(cCriticalSection * a_CS);
- cCSLock(cCriticalSection & a_CS);
- ~cCSLock();
-
- // Temporarily unlock or re-lock:
- void Lock(void);
- void Unlock(void);
-
-private:
- DISALLOW_COPY_AND_ASSIGN(cCSLock);
-} ;
-
-
-
-
-
-/// Temporary RAII unlock for a cCSLock. Useful for unlock-wait-relock scenarios
-class cCSUnlock
-{
- cCSLock & m_Lock;
-public:
- cCSUnlock(cCSLock & a_Lock);
- ~cCSUnlock();
-
-private:
- DISALLOW_COPY_AND_ASSIGN(cCSUnlock);
-} ;
-
-
-
-
+
+#pragma once
+
+
+
+
+
+class cCriticalSection
+{
+public:
+ cCriticalSection(void);
+ ~cCriticalSection();
+
+ void Lock(void);
+ void Unlock(void);
+
+private:
+
+ #ifdef _WIN32
+ CRITICAL_SECTION m_CriticalSection;
+ #else // _WIN32
+ void* m_CriticalSectionPtr ALIGN_8; // Pointer to a CRITICAL_SECTION object
+ void* m_Attributes ALIGN_8;
+ #endif // else _WIN32
+} ALIGN_8;
+
+
+
+
+/// RAII for cCriticalSection - locks the CS on creation, unlocks on destruction
+class cCSLock
+{
+ cCriticalSection * m_CS;
+
+ // 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;
+
+public:
+ cCSLock(cCriticalSection * a_CS);
+ cCSLock(cCriticalSection & a_CS);
+ ~cCSLock();
+
+ // Temporarily unlock or re-lock:
+ void Lock(void);
+ void Unlock(void);
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(cCSLock);
+} ;
+
+
+
+
+
+/// Temporary RAII unlock for a cCSLock. Useful for unlock-wait-relock scenarios
+class cCSUnlock
+{
+ cCSLock & m_Lock;
+public:
+ cCSUnlock(cCSLock & a_Lock);
+ ~cCSUnlock();
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(cCSUnlock);
+} ;
+
+
+
+