From d961f42c7f709929258c2a5b33fbb47acc399522 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 2 Jul 2012 20:37:03 +0000 Subject: - mir_cslock - class for locking critical sections; - unneeded helpers removed; - code cleaning in TTB git-svn-id: http://svn.miranda-ng.org/main/trunk@727 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_system_cpp.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index 76556160a6..0b79d4d552 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -33,9 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #if defined(__cplusplus) -#define NumericKeySortT -1 -#define HandleKeySortT -2 -#define PtrKeySortT -3 +/////////////////////////////////////////////////////////////////////////////// +// mir_ptr - automatic pointer for buffers, allocated using mir_alloc/mir_calloc template class mir_ptr { @@ -51,6 +50,25 @@ public: __inline operator INT_PTR() const { return (INT_PTR)data; } }; +/////////////////////////////////////////////////////////////////////////////// +// mir_cslock - automatic locker for the critical sections + +class mir_cslock +{ + CRITICAL_SECTION& cs; + +public: + __inline mir_cslock(CRITICAL_SECTION& _cs) : cs(_cs) { EnterCriticalSection(&cs); } + __inline ~mir_cslock() { LeaveCriticalSection(&cs); } +}; + +/////////////////////////////////////////////////////////////////////////////// +// general lists' templates + +#define NumericKeySortT -1 +#define HandleKeySortT -2 +#define PtrKeySortT -3 + template struct LIST { typedef int (*FTSortFunc)(const T* p1, const T* p2); -- cgit v1.2.3