diff options
author | George Hazan <george.hazan@gmail.com> | 2012-09-27 12:37:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-09-27 12:37:42 +0000 |
commit | 3ef638023d476a91128f287fe454b547836a4b90 (patch) | |
tree | 46c8e3340f5ce59fdb8bce2ef758e3c32d78fb01 /protocols/MRA/Sdk/ListMT.h | |
parent | 6035c2ae283bd8743a7484ed8796bd845afec4d5 (diff) |
automatic lock management
git-svn-id: http://svn.miranda-ng.org/main/trunk@1680 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/Sdk/ListMT.h')
-rw-r--r-- | protocols/MRA/Sdk/ListMT.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/protocols/MRA/Sdk/ListMT.h b/protocols/MRA/Sdk/ListMT.h index d7ca6e0b12..38d9247488 100644 --- a/protocols/MRA/Sdk/ListMT.h +++ b/protocols/MRA/Sdk/ListMT.h @@ -126,18 +126,20 @@ __inline BOOL ListMTTryLock(PCLIST_MT pclmtListMT) #endif
}
-
-__inline void ListMTLock(PCLIST_MT pclmtListMT)
+class mt_lock
{
- EnterCriticalSection(&pclmtListMT->cs);
-}
+ PCLIST_MT m_list;
+public:
+ __forceinline mt_lock(PCLIST_MT _pList) :
+ m_list( _pList )
+ { EnterCriticalSection(&_pList->cs);
+ }
-__inline void ListMTUnLock(PCLIST_MT pclmtListMT)
-{
- LeaveCriticalSection(&pclmtListMT->cs);
-}
-
+ __forceinline ~mt_lock()
+ { LeaveCriticalSection(&m_list->cs);
+ }
+};
__inline size_t ListMTGetCount(PCLIST_MT pclmtListMT)
{
|