Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Queue_impl
view BlockingQueue.h @ 47:8c0dcf6e15e6
new branch -- PR_univ -- changed header to include PR__application.h
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Mon, 22 Jul 2013 07:05:57 -0700 |
| parents | 67c7f5a0308b |
| children | 1ea30ca7093c |
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 "PR__application_includes/PR__application.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 int32 count;
29 int32 readPos;
30 int32 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 int32 insertLock;
46 volatile int32 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 { int32 lastQReadFrom;
79 int32 numInternalQs;
80 int32 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 */
