summaryrefslogtreecommitdiff
path: root/include/m_system_cpp.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-02 20:37:03 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-02 20:37:03 +0000
commitd961f42c7f709929258c2a5b33fbb47acc399522 (patch)
tree9582b5cc8adc3c74cb9abd0eda60fe910617f154 /include/m_system_cpp.h
parent5e81836e642adcbed92f9fdaa32afb80546e3aee (diff)
- 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
Diffstat (limited to 'include/m_system_cpp.h')
-rw-r--r--include/m_system_cpp.h24
1 files changed, 21 insertions, 3 deletions
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 T> 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<class T> struct LIST
{
typedef int (*FTSortFunc)(const T* p1, const T* p2);