summaryrefslogtreecommitdiffstats
path: root/source/OSSupport/CriticalSection.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2013-11-27 09:23:17 +0100
committerMattes D <github@xoft.cz>2013-11-27 09:23:17 +0100
commit49760db89d94ede5d123d927141a6cd60dbaaf07 (patch)
tree6c6cf99e4cf3128311a93cd187947b502f3732a0 /source/OSSupport/CriticalSection.h
parentcWorld::SpawnExperienceOrb() now returns the entity ID of the spawned orb. (diff)
parentFixed VC2008 compilation, normalized include paths. (diff)
downloadcuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar
cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.gz
cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.bz2
cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.lz
cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.xz
cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.zst
cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.zip
Diffstat (limited to 'source/OSSupport/CriticalSection.h')
-rw-r--r--source/OSSupport/CriticalSection.h80
1 files changed, 0 insertions, 80 deletions
diff --git a/source/OSSupport/CriticalSection.h b/source/OSSupport/CriticalSection.h
deleted file mode 100644
index 1bfe81439..000000000
--- a/source/OSSupport/CriticalSection.h
+++ /dev/null
@@ -1,80 +0,0 @@
-
-#pragma once
-
-
-
-
-
-class cCriticalSection
-{
-public:
- cCriticalSection(void);
- ~cCriticalSection();
-
- void Lock(void);
- void Unlock(void);
-
- #ifdef _DEBUG
- bool IsLocked(void);
- bool IsLockedByCurrentThread(void);
- #endif // _DEBUG
-
-private:
- #ifdef _DEBUG
- int m_IsLocked; // Number of times this CS is locked
- unsigned long m_OwningThreadID;
- #endif // _DEBUG
-
- #ifdef _WIN32
- CRITICAL_SECTION m_CriticalSection;
- #else // _WIN32
- pthread_mutex_t m_CriticalSection;
- pthread_mutexattr_t m_Attributes;
- #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);
-} ;
-
-
-
-