comparison BlockingQueue.h @ 50:93a5782d064b

adding netbeans project directories to repository
author Sean Halle <seanhalle@yahoo.com>
date Fri, 14 Feb 2014 07:54:22 -0800
parents 1ea30ca7093c
children
comparison
equal deleted inserted replaced
9:d2d1bbbac29e 10:fdc7146df95d
6 */ 6 */
7 7
8 #ifndef _BLOCKINGQUEUE_H 8 #ifndef _BLOCKINGQUEUE_H
9 #define _BLOCKINGQUEUE_H 9 #define _BLOCKINGQUEUE_H
10 10
11 #include "PR__common_includes/PR__primitive_data_types.h" 11 #include <PR__include/PR__primitive_data_types.h>
12 #include <PR__include/prmalloc.h>
12 13
13 14
14 #define TRUE 1 15 #define TRUE 1
15 #define FALSE 0 16 #define FALSE 0
16 17
17 #define LOCKED 1 18 #define LOCKED 1
18 #define UNLOCKED 0 19 #define UNLOCKED 0
19 20
20
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;
36
37 PThdQueueStruc* makePThdQ();
38 void* readPThdQ( PThdQueueStruc *Q );
39 void writePThdQ( void *in, PThdQueueStruc *Q );
40
41
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;
53
54 CASQueueStruc* makeCASQ();
55 void* readCASQ( CASQueueStruc *Q );
56 void writeCASQ( void *in, CASQueueStruc *Q );
57
58
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;
68
69 SRSWQueueStruc* makeSRSWQ();
70 void freeSRSWQ( SRSWQueueStruc* Q );
71 void* readSRSWQ( SRSWQueueStruc *Q );
72 void writeSRSWQ( void *in, SRSWQueueStruc *Q );
73
74
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;
84
85 SRMWQueueStruc* makeSRMWQ();
86 int addWriterToSRMWQ( SRMWQueueStruc *Q );
87 void* readSRMWQ( SRMWQueueStruc *Q );
88 void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID );
89
90
91 #endif /* _BLOCKINGQUEUE_H */ 21 #endif /* _BLOCKINGQUEUE_H */
92 22