diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-30 06:20:19 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-30 06:20:19 +0000 |
commit | 2926b727b08fafd10e2429dac0efc21505b850e3 (patch) | |
tree | f79b63fae8f9787cd10d6b72621ea82ddb9651e9 /plugins/UserInfoEx | |
parent | 2f0617376dcb4be5b837c5f888762e4e1ef3aceb (diff) |
minus critical section
git-svn-id: http://svn.miranda-ng.org/main/trunk@13273 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/UserInfoEx')
-rw-r--r-- | plugins/UserInfoEx/src/ctrl_button.cpp | 10 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/mir_contactqueue.cpp | 62 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/mir_contactqueue.h | 11 |
3 files changed, 16 insertions, 67 deletions
diff --git a/plugins/UserInfoEx/src/ctrl_button.cpp b/plugins/UserInfoEx/src/ctrl_button.cpp index 8a85a81947..7bcb7980b6 100644 --- a/plugins/UserInfoEx/src/ctrl_button.cpp +++ b/plugins/UserInfoEx/src/ctrl_button.cpp @@ -45,7 +45,7 @@ typedef struct TMBCtrl{ } BTNCTRL, *LPBTNCTRL;
// External theme methods and properties
-static CRITICAL_SECTION csTips;
+static mir_cs csTips;
static HWND hwndToolTips = NULL;
/**
@@ -379,7 +379,7 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L }
case WM_DESTROY:
if (bct) {
- EnterCriticalSection(&csTips);
+ mir_cslock lck(csTips);
if (hwndToolTips) {
TOOLINFO ti;
@@ -396,7 +396,6 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L hwndToolTips = NULL;
}
}
- LeaveCriticalSection(&csTips);
DestroyTheme(bct);
mir_free(bct);
}
@@ -508,7 +507,7 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L break;
case BUTTONADDTOOLTIP:
if (wParam) {
- EnterCriticalSection(&csTips);
+ mir_cslock lck(csTips);
if (!hwndToolTips)
hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
@@ -544,7 +543,6 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L ti.lpszText=(LPSTR)wParam;
SendMessage(hwndToolTips, TTM_ADDTOOLA, 0, (LPARAM)&ti);
}
- LeaveCriticalSection(&csTips);
}
break;
case BUTTONTRANSLATE:
@@ -626,7 +624,6 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L void CtrlButtonUnloadModule()
{
- DeleteCriticalSection(&csTips);
UnregisterClass(UINFOBUTTONCLASS, ghInst);
}
@@ -642,6 +639,5 @@ void CtrlButtonLoadModule() wc.cbWndExtra = sizeof(LPBTNCTRL);
wc.style = CS_GLOBALCLASS;
RegisterClassEx(&wc);
- InitializeCriticalSection(&csTips);
}
diff --git a/plugins/UserInfoEx/src/mir_contactqueue.cpp b/plugins/UserInfoEx/src/mir_contactqueue.cpp index b06593d1bd..c7c2e8da97 100644 --- a/plugins/UserInfoEx/src/mir_contactqueue.cpp +++ b/plugins/UserInfoEx/src/mir_contactqueue.cpp @@ -49,8 +49,6 @@ CContactQueue::CContactQueue(int initialSize) _hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
_status = RUNNING;
- InitializeCriticalSection(&_cs);
-
mir_forkthread((pThreadFunc)CContactQueue::ThreadProc, this);
}
@@ -77,25 +75,6 @@ CContactQueue::~CContactQueue() }
CloseHandle(_hEvent);
- DeleteCriticalSection(&_cs);
-}
-
-/**
- *
- *
- **/
-void CContactQueue::Lock()
-{
- EnterCriticalSection(&_cs);
-}
-
-/**
- *
- *
- **/
-void CContactQueue::Release()
-{
- LeaveCriticalSection(&_cs);
}
/**
@@ -107,13 +86,11 @@ void CContactQueue::Release() **/
void CContactQueue::RemoveAll()
{
- Lock();
+ mir_cslock lck(_cs);
for (int i = _queue.getCount() - 1; i >= 0; --i)
mir_free(_queue[i]);
_queue.destroy();
-
- Release();
}
/**
@@ -125,7 +102,7 @@ void CContactQueue::RemoveAll() **/
void CContactQueue::RemoveAll(MCONTACT hContact)
{
- Lock();
+ mir_cslock lck(_cs);
for (int i = _queue.getCount() - 1; i >= 0; --i)
{
@@ -137,8 +114,6 @@ void CContactQueue::RemoveAll(MCONTACT hContact) mir_free(qi);
}
}
-
- Release();
}
/**
@@ -151,7 +126,7 @@ void CContactQueue::RemoveAll(MCONTACT hContact) **/
void CContactQueue::RemoveAllConsiderParam(MCONTACT hContact, PVOID param)
{
- Lock();
+ mir_cslock lck(_cs);
for (int i = _queue.getCount() - 1; i >= 0; --i)
{
@@ -163,8 +138,6 @@ void CContactQueue::RemoveAllConsiderParam(MCONTACT hContact, PVOID param) mir_free(qi);
}
}
-
- Release();
}
/**
@@ -181,12 +154,10 @@ BOOL CContactQueue::Add(int waitTime, MCONTACT hContact, PVOID param) {
BOOL rc;
- Lock();
+ mir_cslock lck(_cs);
rc = InternalAdd(waitTime, hContact, param);
- Release();
-
return rc;
}
@@ -206,7 +177,7 @@ BOOL CContactQueue::AddIfDontHave(int waitTime, MCONTACT hContact, PVOID param) int i;
BOOL rc;
- Lock();
+ mir_cslock lck(_cs);
for (i = _queue.getCount() - 1; i >= 0; --i)
{
@@ -218,8 +189,6 @@ BOOL CContactQueue::AddIfDontHave(int waitTime, MCONTACT hContact, PVOID param) rc = (i == -1) ? InternalAdd(waitTime, hContact, param) : 0;
- Release();
-
return rc;
}
@@ -239,13 +208,11 @@ BOOL CContactQueue::AddUnique(int waitTime, MCONTACT hContact, PVOID param) {
BOOL rc;
- Lock();
+ mir_cslock lck(_cs);
RemoveAll(hContact);
rc = InternalAdd(waitTime, hContact, param);
- Release();
-
return rc;
}
@@ -265,13 +232,11 @@ BOOL CContactQueue::AddUniqueConsiderParam(int waitTime, MCONTACT hContact, PVOI {
BOOL rc;
- Lock();
+ mir_cslock lck(_cs);
RemoveAllConsiderParam(hContact, param);
rc = InternalAdd(waitTime, hContact, param);
- Release();
-
return rc;
}
@@ -322,16 +287,13 @@ void CContactQueue::Thread() {
ResetEvent(_hEvent);
- Lock();
+ mir_cslock lck(_cs);
if (_queue.getCount() <= 0)
{
// can be used by a derivant
OnEmpty();
- // No items, so supend thread
- Release();
-
Suspend(INFINITE);
}
else
@@ -342,9 +304,6 @@ void CContactQueue::Thread() int dt = qi->check_time - GetTickCount();
if (dt > 0)
{
- // Not time to request yet, wait...
- Release();
-
Suspend(dt);
}
else
@@ -352,8 +311,6 @@ void CContactQueue::Thread() // Will request this queue item
_queue.remove(0);
- Release();
-
Callback(qi->hContact, qi->param);
mir_free(qi);
@@ -391,7 +348,7 @@ void CContactQueue::ContinueWithNext() {
int i, c, dt;
- Lock();
+ mir_cslock lck(_cs);
c = _queue.getCount();
if (c > 0)
@@ -406,6 +363,5 @@ void CContactQueue::ContinueWithNext() }
}
SetEvent(_hEvent);
- Release();
}
}
diff --git a/plugins/UserInfoEx/src/mir_contactqueue.h b/plugins/UserInfoEx/src/mir_contactqueue.h index a426701e19..32ccdd1eaa 100644 --- a/plugins/UserInfoEx/src/mir_contactqueue.h +++ b/plugins/UserInfoEx/src/mir_contactqueue.h @@ -179,14 +179,11 @@ protected: private:
- LIST<CQueueItem> _queue;
+ LIST<CQueueItem> _queue;
- CRITICAL_SECTION _cs;
- HANDLE _hEvent;
- EQueueStatus _status;
-
- void Lock();
- void Release();
+ mir_cs _cs;
+ HANDLE _hEvent;
+ EQueueStatus _status;
/**
* This member function really adds an item into the time sorted queue list.
|