diff options
author | Rozhuk Ivan <rozhuk.im@gmail.com> | 2015-02-09 14:18:38 +0000 |
---|---|---|
committer | Rozhuk Ivan <rozhuk.im@gmail.com> | 2015-02-09 14:18:38 +0000 |
commit | 753572a30e7eb2b44b3937f3854ecfe172833a62 (patch) | |
tree | af39aae8f516e5d3bed134753b05565cdf1dcd53 /protocols/MRA/src/MraAvatars.cpp | |
parent | 9e791b8e15d0d5d8686436ed9eee010e670b858b (diff) |
mra: avatars improvements
git-svn-id: http://svn.miranda-ng.org/main/trunk@12064 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/src/MraAvatars.cpp')
-rw-r--r-- | protocols/MRA/src/MraAvatars.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index 2c709a8a3c..4a18383b8d 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -106,6 +106,7 @@ void CMraProto::MraAvatarsQueueSuspend(HANDLE hAvatarsQueueHandle) {
MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, FALSE);
+ MraAvatarsQueueClear(hAvatarsQueueHandle);
SetEvent(pmraaqAvatarsQueue->hThreadEvent);
}
@@ -115,15 +116,15 @@ void CMraProto::MraAvatarsQueueDestroy(HANDLE hAvatarsQueueHandle) return;
MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
- while (InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount, 0))
- SleepEx(100, TRUE);
+ while (InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount, 0)) {
+ SetEvent(pmraaqAvatarsQueue->hThreadEvent);
+ SleepEx(50, TRUE);
+ }
for (int i = 0; i < pmraaqAvatarsQueue->iThreadsCount; i++)
CloseHandle(pmraaqAvatarsQueue->hThread[i]);
CloseHandle(pmraaqAvatarsQueue->hThreadEvent);
- MraAvatarsQueueClear(hAvatarsQueueHandle);
-
Netlib_CloseHandle(pmraaqAvatarsQueue->hNetlibUser);
delete pmraaqAvatarsQueue;
}
@@ -134,6 +135,9 @@ DWORD CMraProto::MraAvatarsQueueAdd(HANDLE hAvatarsQueueHandle, DWORD dwFlags, M return ERROR_INVALID_HANDLE;
MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
+ if (!InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, 0))
+ return ERROR_INVALID_HANDLE;
+
MRA_AVATARS_QUEUE_ITEM *pmraaqiAvatarsQueueItem = (MRA_AVATARS_QUEUE_ITEM*)mir_calloc(sizeof(MRA_AVATARS_QUEUE_ITEM));
if (!pmraaqiAvatarsQueueItem)
return GetLastError();
|