summaryrefslogtreecommitdiff
path: root/protocols/MRA/Sdk
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/MRA/Sdk')
-rw-r--r--protocols/MRA/Sdk/FIFOMT.h34
-rw-r--r--protocols/MRA/Sdk/ListMT.h20
2 files changed, 20 insertions, 34 deletions
diff --git a/protocols/MRA/Sdk/FIFOMT.h b/protocols/MRA/Sdk/FIFOMT.h
index d15ae3e596..acff96f500 100644
--- a/protocols/MRA/Sdk/FIFOMT.h
+++ b/protocols/MRA/Sdk/FIFOMT.h
@@ -62,13 +62,8 @@ typedef PCLIST_MT_ITERATOR PCFIFO_MT_ITERATOR, LPCFIFO_MT_ITERATOR;
__inline size_t FifoMTItemPush(PCFIFO_MT pcpmtFifoMT,PCFIFO_MT_ITEM pcffmtiFifoItem,LPVOID lpData)
{
- size_t dwRet;
-
- ListMTLock(pcpmtFifoMT);
- dwRet=ListMTItemAdd(pcpmtFifoMT,pcffmtiFifoItem,lpData);
- ListMTUnLock(pcpmtFifoMT);
-
-return(dwRet);
+ mt_lock l(pcpmtFifoMT);
+ return ListMTItemAdd(pcpmtFifoMT,pcffmtiFifoItem,lpData);
}
@@ -77,39 +72,28 @@ __inline DWORD FifoMTItemPop(PCFIFO_MT pcpmtFifoMT,PFIFO_MT_ITEM *ppffmtiFifoIte
DWORD dwRetErrorCode;
PLIST_MT_ITEM plmtiItem;
- ListMTLock(pcpmtFifoMT);
+ mt_lock l(pcpmtFifoMT);
if ((dwRetErrorCode=ListMTItemGetFirst(pcpmtFifoMT,&plmtiItem,plpData))==NO_ERROR)
{
if (ppffmtiFifoItem) (*ppffmtiFifoItem)=plmtiItem;
- dwRetErrorCode=ListMTItemDelete(pcpmtFifoMT,plmtiItem);
+ return ListMTItemDelete(pcpmtFifoMT,plmtiItem);
}
- ListMTUnLock(pcpmtFifoMT);
-return(dwRetErrorCode);
+ return dwRetErrorCode;
}
__inline DWORD FifoMTItemGetFirst(PCFIFO_MT pcpmtFifoMT,PFIFO_MT_ITEM *ppffmtiFifoItem,LPVOID *plpData)
{
- DWORD dwRetErrorCode;
-
- ListMTLock(pcpmtFifoMT);
- dwRetErrorCode=ListMTItemGetFirst(pcpmtFifoMT,ppffmtiFifoItem,plpData);
- ListMTUnLock(pcpmtFifoMT);
-
-return(dwRetErrorCode);
+ mt_lock l(pcpmtFifoMT);
+ return ListMTItemGetFirst(pcpmtFifoMT,ppffmtiFifoItem,plpData);
}
__inline DWORD FifoMTItemGetLast(PCFIFO_MT pcpmtFifoMT,PFIFO_MT_ITEM *ppffmtiFifoItem,LPVOID *plpData)
{
- DWORD dwRetErrorCode;
-
- ListMTLock(pcpmtFifoMT);
- dwRetErrorCode=ListMTItemGetLast(pcpmtFifoMT,ppffmtiFifoItem,plpData);
- ListMTUnLock(pcpmtFifoMT);
-
-return(dwRetErrorCode);
+ mt_lock l(pcpmtFifoMT);
+ return ListMTItemGetLast(pcpmtFifoMT,ppffmtiFifoItem,plpData);
}
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)
{