Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Queue_impl
view BlockingQueue.h @ 34:c5d2f2a94133
updated to fixed versions from MC_shared brch, then removed VMS_ from malloc
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 14 Mar 2012 23:02:28 -0700 |
| parents | 228ca5487d81 |
| children | 62326cc8e6f4 b5ae7fbb1f01 |
line source
1 /*
2 * File: BlockingQueue.h
3 * Author: SeanHalle@yahoo.com
4 *
5 * Created on November 11, 2009, 12:51 PM
6 */
8 #ifndef _BLOCKINGQUEUE_H
9 #define _BLOCKINGQUEUE_H
11 #include "pthread.h"
14 #define TRUE 1
15 #define FALSE 0
17 #define LOCKED 1
18 #define UNLOCKED 0
21 //========== pThreads based queue ==========
22 /* It is the data that is shared so only need one mutex. */
23 typedef
24 struct
25 { pthread_mutex_t mutex_t;
26 pthread_cond_t cond_w_t;
27 pthread_cond_t cond_r_t;
28 int count;
29 int readPos;
30 int writePos;
31 void* data[1024]; //an array of pointers
32 int w_empty;
33 int w_full;
34 }
35 PThdQueueStruc;
37 PThdQueueStruc* makePThdQ();
38 void* readPThdQ( PThdQueueStruc *Q );
39 void writePThdQ( void *in, PThdQueueStruc *Q );
42 //========== CAS based queue ==========
43 typedef
44 struct
45 { volatile int insertLock;
46 volatile int extractLock;
47 volatile void* *insertPos;
48 volatile void* *extractPos;
49 void* startOfData[1024]; //data is pointers
50 void* *endOfData; //set when make queue
51 }
52 CASQueueStruc;
54 CASQueueStruc* makeCASQ();
55 void* readCASQ( CASQueueStruc *Q );
56 void writeCASQ( void *in, CASQueueStruc *Q );
59 //========= non-atomic instr based queue ===========
60 typedef
61 struct
62 { void* *insertPos;
63 void* *extractPos;
64 void* startOfData[1024]; //data is pointers
65 void* *endOfData; //set when make queue
66 }
67 SRSWQueueStruc;
69 SRSWQueueStruc* makeSRSWQ();
70 void freeSRSWQ( SRSWQueueStruc* Q );
71 void* readSRSWQ( SRSWQueueStruc *Q );
72 void writeSRSWQ( void *in, SRSWQueueStruc *Q );
75 //========= non-atomic instr S R M W queue ===========
76 typedef
77 struct
78 { int lastQReadFrom;
79 int numInternalQs;
80 int internalQsSz;
81 SRSWQueueStruc* *internalQs;
82 }
83 SRMWQueueStruc;
85 SRMWQueueStruc* makeSRMWQ();
86 int addWriterToSRMWQ( SRMWQueueStruc *Q );
87 void* readSRMWQ( SRMWQueueStruc *Q );
88 void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID );
91 #endif /* _BLOCKINGQUEUE_H */
