From a1a5930ab1f10f6e65fe609ee4ce0bcef4459bc1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 12 Jul 2014 20:32:21 +0000 Subject: useful wrapper for critical sections git-svn-id: http://svn.miranda-ng.org/main/trunk@9779 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_system_cpp.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 @@ -59,6 +59,20 @@ typedef mir_ptr ptrA; typedef mir_ptr ptrT; typedef mir_ptr 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 -- cgit v1.2.3