summaryrefslogtreecommitdiff
path: root/include/m_system_cpp.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-21 07:30:30 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-21 07:30:30 +0000
commit9550917a49f7046389cfdd8158061477106289bd (patch)
tree09436a5a38c12f3802dc8bee0a48114b701a659e /include/m_system_cpp.h
parentcd043bfeb73e6db61adccacdf284c81c95cf0c57 (diff)
controllable critical section locker
git-svn-id: http://svn.miranda-ng.org/main/trunk@1088 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include/m_system_cpp.h')
-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