summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-12 20:32:21 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-12 20:32:21 +0000
commita1a5930ab1f10f6e65fe609ee4ce0bcef4459bc1 (patch)
treecffa73662c5a7638d29cb151e679ab5a8c79e714
parenta5d4df47638c42d9bc3d5d126984d9e15e2e1678 (diff)
useful wrapper for critical sections
git-svn-id: http://svn.miranda-ng.org/main/trunk@9779 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_system_cpp.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h
index fa2a13b4b0..8e887ff13f 100644
--- a/include/m_system_cpp.h
+++ b/include/m_system_cpp.h
@@ -60,6 +60,20 @@ typedef mir_ptr<TCHAR> ptrT;
typedef mir_ptr<WCHAR> ptrW;
///////////////////////////////////////////////////////////////////////////////
+// mir_cs - simple wrapper for the critical sections
+
+class mir_cs
+{
+ CRITICAL_SECTION m_cs;
+
+public:
+ __inline mir_cs() { ::InitializeCriticalSection(&m_cs); }
+ __inline ~mir_cs() { ::DeleteCriticalSection(&m_cs); }
+
+ __inline operator CRITICAL_SECTION&() { return m_cs; }
+};
+
+///////////////////////////////////////////////////////////////////////////////
// mir_cslock - simple locker for the critical sections
class mir_cslock