Massive patch for the first months work adding System FC to GHC #35
[ghc-hetmet.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 #ifndef __WORKQUEUE_H__
9 #define __WORKQUEUE_H__
10 #include <windows.h>
11
12 /* This is a fixed-size queue. */
13 #define WORKQUEUE_SIZE 16
14
15 typedef HANDLE           Semaphore;
16 typedef CRITICAL_SECTION CritSection;
17
18 typedef struct WorkQueue {
19     /* the master lock, need to be grabbed prior to
20        using any of the other elements of the struct. */
21   CritSection   queueLock;
22   /* consumers/workers block waiting for 'workAvailable' */
23   Semaphore     workAvailable;
24   Semaphore     roomAvailable;
25   int           head;
26   int           tail;
27   void**        items[WORKQUEUE_SIZE];
28 } WorkQueue;
29
30 extern WorkQueue* NewWorkQueue       ( void );
31 extern void       FreeWorkQueue      ( WorkQueue* pq );
32 extern HANDLE     GetWorkQueueHandle ( WorkQueue* pq );
33 extern BOOL       GetWork            ( WorkQueue* pq, void** ppw );
34 extern BOOL       FetchWork          ( WorkQueue* pq, void** ppw );
35 extern int        SubmitWork         ( WorkQueue* pq, void*   pw );
36
37 #endif /* __WORKQUEUE_H__ */