summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/m_system_cpp.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h
index ea8098f24a..4c8656b4e2 100644
--- a/include/m_system_cpp.h
+++ b/include/m_system_cpp.h
@@ -51,7 +51,7 @@ public:
};
///////////////////////////////////////////////////////////////////////////////
-// mir_cslock - automatic locker for the critical sections
+// mir_cslock - simple locker for the critical sections
class mir_cslock
{
@@ -63,6 +63,22 @@ public:
};
///////////////////////////////////////////////////////////////////////////////
+// mir_cslockfull - controllable locker for the critical sections
+
+class mir_cslockfull
+{
+ CRITICAL_SECTION& cs;
+ bool bIsLocked;
+
+public:
+ __inline void lock() { bIsLocked = true; EnterCriticalSection(&cs); }
+ __inline void unlock() { bIsLocked = false; LeaveCriticalSection(&cs); }
+
+ __inline mir_cslockfull(CRITICAL_SECTION& _cs) : cs(_cs) { lock(); }
+ __inline ~mir_cslockfull() { if (bIsLocked) unlock(); }
+};
+
+///////////////////////////////////////////////////////////////////////////////
// basic class for classes that should be cleared inside new()
class MZeroedObject