summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/request_queue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/SkypeWeb/src/request_queue.cpp')
-rw-r--r--protocols/SkypeWeb/src/request_queue.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/protocols/SkypeWeb/src/request_queue.cpp b/protocols/SkypeWeb/src/request_queue.cpp
index 2a7e384a8f..e932dc363d 100644
--- a/protocols/SkypeWeb/src/request_queue.cpp
+++ b/protocols/SkypeWeb/src/request_queue.cpp
@@ -64,6 +64,12 @@ void RequestQueue::Push(HttpRequest *request, HttpResponseCallback response, voi
SetEvent(hRequestQueueEvent);
}
+void RequestQueue::Send(HttpRequest *request, HttpResponseCallback response, void *arg)
+{
+ RequestQueueItem *item = new RequestQueueItem(request, response, arg);
+ mir_forkthreadowner((pThreadFuncOwner)&RequestQueue::AsyncSendThread, this, item, 0);
+}
+
void RequestQueue::Execute(RequestQueueItem *item)
{
NETLIBHTTPREQUEST *response = item->request->Send(hConnection);
@@ -74,27 +80,37 @@ void RequestQueue::Execute(RequestQueueItem *item)
delete item;
}
-unsigned int RequestQueue::WorkerThread(void* owner, void*)
+unsigned int RequestQueue::AsyncSendThread(void *owner, void *arg)
{
RequestQueue *that = (RequestQueue*)owner;
+ RequestQueueItem *item = (RequestQueueItem*)arg;
+
+ that->Execute(item);
+
+ return 0;
+}
+
+unsigned int RequestQueue::WorkerThread(void *arg)
+{
+ RequestQueue *queue = (RequestQueue*)arg;
- while (!that->isTerminated)
+ while (!queue->isTerminated)
{
- WaitForSingleObject(that->hRequestQueueEvent, INFINITE);
+ WaitForSingleObject(queue->hRequestQueueEvent, INFINITE);
while (true)
{
RequestQueueItem *item = NULL;
{
- mir_cslock lock(that->requestQueueLock);
+ mir_cslock lock(queue->requestQueueLock);
- if (that->requests.getCount() == 0)
+ if (queue->requests.getCount() == 0)
break;
- item = that->requests[0];
- that->requests.remove(0);
+ item = queue->requests[0];
+ queue->requests.remove(0);
}
if (item != NULL)
- that->Execute(item);
+ queue->Execute(item);
}
}