summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/threaded_queue.h
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/threaded_queue.h')
-rwxr-xr-xwinsup/cygwin/threaded_queue.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/winsup/cygwin/threaded_queue.h b/winsup/cygwin/threaded_queue.h
new file mode 100755
index 000000000..b330d96ac
--- /dev/null
+++ b/winsup/cygwin/threaded_queue.h
@@ -0,0 +1,67 @@
+/* threaded_queue.h
+
+ Copyright 2001 Red Hat Inc.
+
+ Written by Robert Collins <rbtcollins@hotmail.com>
+
+ This file is part of Cygwin.
+
+ This software is a copyrighted work licensed under the terms of the
+ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+ details. */
+
+#ifndef _THREADED_QUEUE_
+#define _THREADED_QUEUE_
+
+/* a specific request */
+
+class queue_request
+{
+ public:
+ class queue_request *next;
+ virtual void process ();
+ queue_request();
+};
+
+
+typedef DWORD WINAPI threaded_queue_thread_function (LPVOID);
+/* parameters for a request finding and submitting loop */
+
+class queue_process_param
+{
+ public:
+ bool start (threaded_queue_thread_function *, class threaded_queue *);
+ void stop ();
+ bool running;
+ long int shutdown;
+ class queue_process_param * next;
+ class threaded_queue *queue;
+ queue_process_param (bool ninterruptible);
+ ~queue_process_param ();
+ bool interruptible;
+ HANDLE interrupt;
+ HANDLE hThread;
+ DWORD tid;
+};
+
+/* a queue to allocate requests from n submission loops to x worker threads */
+
+class threaded_queue
+{
+ public:
+ CRITICAL_SECTION queuelock;
+ HANDLE event;
+ bool active;
+ queue_request * request;
+ unsigned int initial_workers;
+ unsigned int running;
+ void create_workers ();
+ void cleanup ();
+ void add (queue_request *);
+ void process_requests (queue_process_param *, threaded_queue_thread_function *);
+ threaded_queue () : active (false), request (NULL), initial_workers (1), running (0), process_head (NULL) {};
+ private:
+ queue_request *process_head;
+};
+
+#endif /* _THREADED_QUEUE_ */