~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to rts/win32/WorkQueue.h

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* WorkQueue.h
 
2
 *
 
3
 * A fixed-size queue; MT-friendly.
 
4
 * 
 
5
 * (c) sof, 2002-2003
 
6
 *
 
7
 */
 
8
 
 
9
#ifndef WIN32_WORKQUEUE_H
 
10
#define WIN32_WORKQUEUE_H
 
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 );
 
37
 
 
38
#endif /* WIN32_WORKQUEUE_H */