3 * A fixed-size queue; MT-friendly.
9 #ifndef WIN32_WORKQUEUE_H
10 #define WIN32_WORKQUEUE_H
13 /* This is a fixed-size queue. */
14 #define WORKQUEUE_SIZE 16
16 typedef HANDLE Semaphore;
17 typedef CRITICAL_SECTION CritSection;
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;
28 void** items[WORKQUEUE_SIZE];
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 );
38 #endif /* WIN32_WORKQUEUE_H */