summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src/sendqueue.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-13 10:50:59 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-13 10:50:59 +0000
commit5df94ff719eccd04c7450df35fb5e3f2b36e2ee7 (patch)
tree440d736b199ff849ca0619adf355ffc73750ca7f /plugins/Scriver/src/sendqueue.cpp
parent70496fb739225b559a251f4518c946110aef718c (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 'plugins/Scriver/src/sendqueue.cpp')
-rw-r--r--plugins/Scriver/src/sendqueue.cpp38
1 files changed, 12 insertions, 26 deletions
diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp
index 6175c87d22..93deeff0e8 100644
--- a/plugins/Scriver/src/sendqueue.cpp
+++ b/plugins/Scriver/src/sendqueue.cpp
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
static MessageSendQueueItem *global_sendQueue = NULL;
-static CRITICAL_SECTION queueMutex;
+static mir_cs queueMutex;
TCHAR * GetSendBufferMsg(MessageSendQueueItem *item)
{
@@ -41,42 +41,28 @@ TCHAR * GetSendBufferMsg(MessageSendQueueItem *item)
return szMsg;
}
-void InitSendQueue()
-{
- InitializeCriticalSection(&queueMutex);
-}
-
-void DestroySendQueue()
-{
- DeleteCriticalSection(&queueMutex);
-}
-
MessageSendQueueItem* CreateSendQueueItem(HWND hwndSender)
{
- MessageSendQueueItem *item = (MessageSendQueueItem *) mir_alloc(sizeof(MessageSendQueueItem));
- EnterCriticalSection(&queueMutex);
- ZeroMemory(item, sizeof(MessageSendQueueItem));
+ MessageSendQueueItem *item = (MessageSendQueueItem*)mir_calloc(sizeof(MessageSendQueueItem));
+
+ mir_cslock lck(queueMutex);
item->hwndSender = hwndSender;
item->next = global_sendQueue;
- if (global_sendQueue != NULL) {
+ if (global_sendQueue != NULL)
global_sendQueue->prev = item;
- }
+
global_sendQueue = item;
- LeaveCriticalSection(&queueMutex);
return item;
}
MessageSendQueueItem* FindOldestPendingSendQueueItem(HWND hwndSender, MCONTACT hContact)
{
- MessageSendQueueItem *item, *found = NULL;
- EnterCriticalSection(&queueMutex);
- for (item = global_sendQueue; item != NULL; item = item->next) {
- if (item->hwndSender == hwndSender && item->hContact == hContact && item->hwndErrorDlg == NULL) {
- found = item;
- }
- }
- LeaveCriticalSection(&queueMutex);
- return found;
+ mir_cslock lck(queueMutex);
+ for (MessageSendQueueItem *item = global_sendQueue; item != NULL; item = item->next)
+ if (item->hwndSender == hwndSender && item->hContact == hContact && item->hwndErrorDlg == NULL)
+ return item;
+
+ return NULL;
}
MessageSendQueueItem* FindSendQueueItem(MCONTACT hContact, HANDLE hSendId)