diff options
Diffstat (limited to 'rts/win32/WorkQueue.h')
-rw-r--r-- | rts/win32/WorkQueue.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/rts/win32/WorkQueue.h b/rts/win32/WorkQueue.h new file mode 100644 index 0000000000..bde82a3a77 --- /dev/null +++ b/rts/win32/WorkQueue.h @@ -0,0 +1,37 @@ +/* WorkQueue.h + * + * A fixed-size queue; MT-friendly. + * + * (c) sof, 2002-2003 + * + */ +#ifndef __WORKQUEUE_H__ +#define __WORKQUEUE_H__ +#include <windows.h> + +/* This is a fixed-size queue. */ +#define WORKQUEUE_SIZE 16 + +typedef HANDLE Semaphore; +typedef CRITICAL_SECTION CritSection; + +typedef struct WorkQueue { + /* the master lock, need to be grabbed prior to + using any of the other elements of the struct. */ + CritSection queueLock; + /* consumers/workers block waiting for 'workAvailable' */ + Semaphore workAvailable; + Semaphore roomAvailable; + int head; + int tail; + void** items[WORKQUEUE_SIZE]; +} WorkQueue; + +extern WorkQueue* NewWorkQueue ( void ); +extern void FreeWorkQueue ( WorkQueue* pq ); +extern HANDLE GetWorkQueueHandle ( WorkQueue* pq ); +extern BOOL GetWork ( WorkQueue* pq, void** ppw ); +extern BOOL FetchWork ( WorkQueue* pq, void** ppw ); +extern int SubmitWork ( WorkQueue* pq, void* pw ); + +#endif /* __WORKQUEUE_H__ */ |