diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-13 10:50:59 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-13 10:50:59 +0000 |
commit | 5df94ff719eccd04c7450df35fb5e3f2b36e2ee7 (patch) | |
tree | 440d736b199ff849ca0619adf355ffc73750ca7f /protocols/JabberG/src/jabber_rc.h | |
parent | 70496fb739225b559a251f4518c946110aef718c (diff) |
wrapping the most evident critical sections into a class
git-svn-id: http://svn.miranda-ng.org/main/trunk@9785 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_rc.h')
-rw-r--r-- | protocols/JabberG/src/jabber_rc.h | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/protocols/JabberG/src/jabber_rc.h b/protocols/JabberG/src/jabber_rc.h index 526598a5d6..806b42839f 100644 --- a/protocols/JabberG/src/jabber_rc.h +++ b/protocols/JabberG/src/jabber_rc.h @@ -163,7 +163,7 @@ protected: CJabberProto *m_pProto;
CJabberAdhocNode* m_pNodes;
CJabberAdhocSession* m_pSessions;
- CRITICAL_SECTION m_cs;
+ mir_cs m_cs;
CJabberAdhocSession* FindSession(const TCHAR *szSession)
{
@@ -253,26 +253,16 @@ protected: public:
CJabberAdhocManager(CJabberProto* pProto)
{
- ZeroMemory(this, sizeof(CJabberAdhocManager));
m_pProto = pProto;
- InitializeCriticalSection(&m_cs);
+ m_pNodes = NULL;
+ m_pSessions = NULL;
}
~CJabberAdhocManager()
{
- if (m_pNodes)
- delete m_pNodes;
- if (m_pSessions)
- delete m_pSessions;
- DeleteCriticalSection(&m_cs);
- }
- void Lock()
- {
- EnterCriticalSection(&m_cs);
- }
- void Unlock()
- {
- LeaveCriticalSection(&m_cs);
+ delete m_pNodes;
+ delete m_pSessions;
}
+
BOOL FillDefaultNodes();
BOOL AddNode(TCHAR* szJid, TCHAR* szNode, TCHAR* szName, JABBER_ADHOC_HANDLER pHandler)
{
@@ -280,7 +270,7 @@ public: if (!pNode)
return FALSE;
- Lock();
+ mir_cslock lck(m_cs);
if (!m_pNodes)
m_pNodes = pNode;
else {
@@ -289,24 +279,24 @@ public: pTmp = pTmp->GetNext();
pTmp->SetNext(pNode);
}
- Unlock();
-
return TRUE;
}
+
CJabberAdhocNode* GetFirstNode()
{
return m_pNodes;
}
+
BOOL HandleItemsRequest(HXML iqNode, CJabberIqInfo *pInfo, const TCHAR *szNode);
BOOL HandleInfoRequest(HXML iqNode, CJabberIqInfo *pInfo, const TCHAR *szNode);
BOOL HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo, const TCHAR *szNode);
BOOL ExpireSessions()
{
- Lock();
+ mir_cslock lck(m_cs);
DWORD dwExpireTime = GetTickCount() - JABBER_ADHOC_SESSION_EXPIRE_TIME;
- while (_ExpireSession(dwExpireTime));
- Unlock();
+ while (_ExpireSession(dwExpireTime))
+ ;
return TRUE;
}
};
|