cpp: Use #pragma once instead of #ifndef guards
[ghc.git] / rts / win32 / WorkQueue.h
1 /* WorkQueue.h
2 *
3 * A fixed-size queue; MT-friendly.
4 *
5 * (c) sof, 2002-2003
6 *
7 */
8
9 #pragma once
10
11 #include <windows.h>
12
13 /* This is a fixed-size queue. */
14 #define WORKQUEUE_SIZE 16
15
16 typedef HANDLE Semaphore;
17 typedef CRITICAL_SECTION CritSection;
18
19 typedef struct WorkQueue {
20 /* the master lock, need to be grabbed prior to
21 using any of the other elements of the struct. */
22 CritSection queueLock;
23 /* consumers/workers block waiting for 'workAvailable' */
24 Semaphore workAvailable;
25 Semaphore roomAvailable;
26 int head;
27 int tail;
28 void** items[WORKQUEUE_SIZE];
29 } WorkQueue;
30
31 extern WorkQueue* NewWorkQueue ( void );
32 extern void FreeWorkQueue ( WorkQueue* pq );
33 extern HANDLE GetWorkQueueHandle ( WorkQueue* pq );
34 extern BOOL GetWork ( WorkQueue* pq, void** ppw );
35 extern BOOL FetchWork ( WorkQueue* pq, void** ppw );
36 extern int SubmitWork ( WorkQueue* pq, void* pw );