From 3ef638023d476a91128f287fe454b547836a4b90 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 27 Sep 2012 12:37:42 +0000 Subject: automatic lock management git-svn-id: http://svn.miranda-ng.org/main/trunk@1680 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MRA/Sdk/ListMT.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'protocols/MRA/Sdk/ListMT.h') 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) { -- cgit v1.2.3