summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/request_queue.h
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-05-26 19:15:20 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-05-26 19:15:20 +0000
commitab75f8e4a3968c956425844415237a4fa6fcee63 (patch)
treedf2c209dd0197dc3085546606b0581d63f9114ad /protocols/Steam/src/request_queue.h
parent4e9e885747b2037c81ce809f7f6505f8bc8b0e2f (diff)
Steam: merge new api
git-svn-id: http://svn.miranda-ng.org/main/trunk@13850 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/request_queue.h')
-rw-r--r--protocols/Steam/src/request_queue.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/protocols/Steam/src/request_queue.h b/protocols/Steam/src/request_queue.h
new file mode 100644
index 0000000000..3a213be0bf
--- /dev/null
+++ b/protocols/Steam/src/request_queue.h
@@ -0,0 +1,59 @@
+#ifndef _REQUEST_QUEUE_H_
+#define _REQUEST_QUEUE_H_
+
+typedef void(*HttpResponseCallback)(const NETLIBHTTPREQUEST *response, void *arg);
+typedef void(*HttpFinallyCallback)(void *arg);
+
+struct RequestQueueItem
+{
+ void *arg;
+ HttpRequest *request;
+ HttpResponseCallback responseCallback;
+ HttpFinallyCallback finallyCallback;
+
+ RequestQueueItem(HttpRequest *request, void *arg, HttpFinallyCallback finallyCallback) :
+ request(request), responseCallback(NULL), arg(arg), finallyCallback(finallyCallback)
+ {
+ }
+
+ RequestQueueItem(HttpRequest *request, HttpResponseCallback response, void *arg, HttpFinallyCallback finallyCallback) :
+ request(request), responseCallback(response), arg(arg), finallyCallback(finallyCallback)
+ {
+ }
+
+ ~RequestQueueItem()
+ {
+ delete request;
+ request = NULL;
+ responseCallback = NULL;
+ finallyCallback = NULL;
+ }
+};
+
+class RequestQueue
+{
+private:
+ bool isTerminated;
+ HANDLE hConnection;
+ mir_cs requestQueueLock;
+ LIST<RequestQueueItem> requests;
+ HANDLE hRequestQueueEvent, hRequestQueueThread;
+
+ void Execute(RequestQueueItem *item);
+
+ static unsigned int __cdecl AsyncSendThread(void*, void*);
+ static unsigned int __cdecl WorkerThread(void*);
+
+public:
+ RequestQueue(HANDLE hConnection);
+ ~RequestQueue();
+
+ void Start();
+ void Stop();
+
+ void Push(HttpRequest *request, HttpResponseCallback response = NULL, void *arg = NULL, HttpFinallyCallback last = NULL);
+ void Send(HttpRequest *request, HttpResponseCallback response = NULL, void *arg = NULL, HttpFinallyCallback last = NULL);
+
+};
+
+#endif //_REQUEST_QUEUE_H_ \ No newline at end of file