Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Queue_impl
comparison prqueue.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 | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:35ac391e79d1 |
|---|---|
| 1 /* | |
| 2 * Copyright 2009 OpenSourceResearchInstitute.org | |
| 3 * Licensed under GNU General Public License version 2 | |
| 4 * | |
| 5 * Author: seanhalle@yahoo.com | |
| 6 */ | |
| 7 | |
| 8 #ifndef _PRQUEUE_H | |
| 9 #define _PRQUEUE_H | |
| 10 | |
| 11 #include <PR__include/PR__primitive_data_types.h> | |
| 12 #include <pthread.h> | |
| 13 | |
| 14 #define TRUE 1 | |
| 15 #define FALSE 0 | |
| 16 | |
| 17 //================== Private Queue stuff =================== | |
| 18 /* It is the data that is shared so only need one mutex. */ | |
| 19 typedef struct | |
| 20 { void **insertPos; | |
| 21 void **extractPos; | |
| 22 void **startOfData; //data is pointers | |
| 23 void **endOfData; //set when alloc data | |
| 24 } | |
| 25 PrivQueueStruc; | |
| 26 | |
| 27 typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * | |
| 28 | |
| 29 PrivQueueStruc* makePrivQ ( ); | |
| 30 bool32 isEmptyPrivQ ( PrivQueueStruc *Q ); //ret TRUE if empty | |
| 31 void* peekPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty | |
| 32 void* readPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty | |
| 33 void writePrivQ( void *in, PrivQueueStruc *Q ); | |
| 34 //return false when full | |
| 35 bool32 writeIfSpacePrivQ( void * in, PrivQueueStruc* Q ); | |
| 36 int32 numInPrivQ( PrivQueueStruc *Q ); | |
| 37 void pushPrivQ( void * in, PrivQueueStruc* Q ); | |
| 38 void freePrivQ( PrivQueueStruc *Q ); | |
| 39 | |
| 40 | |
| 41 //====================== Parallel Queue Stuff ==================== | |
| 42 | |
| 43 //========== pThreads based queue ========== | |
| 44 /* It is the data that is shared so only need one mutex. */ | |
| 45 typedef | |
| 46 struct | |
| 47 { pthread_mutex_t mutex_t; | |
| 48 pthread_cond_t cond_w_t; | |
| 49 pthread_cond_t cond_r_t; | |
| 50 int32 count; | |
| 51 int32 readPos; | |
| 52 int32 writePos; | |
| 53 void* data[1024]; //an array of pointers | |
| 54 int w_empty; | |
| 55 int w_full; | |
| 56 } | |
| 57 PThdQueueStruc; | |
| 58 | |
| 59 PThdQueueStruc* makePThdQ(); | |
| 60 void* readPThdQ( PThdQueueStruc *Q ); | |
| 61 void writePThdQ( void *in, PThdQueueStruc *Q ); | |
| 62 | |
| 63 | |
| 64 //========== CAS based queue ========== | |
| 65 typedef | |
| 66 struct | |
| 67 { volatile int32 insertLock; | |
| 68 volatile int32 extractLock; | |
| 69 volatile void* *insertPos; | |
| 70 volatile void* *extractPos; | |
| 71 void* startOfData[1024]; //data is pointers | |
| 72 void* *endOfData; //set when make queue | |
| 73 } | |
| 74 CASQueueStruc; | |
| 75 | |
| 76 CASQueueStruc* makeCASQ(); | |
| 77 void* readCASQ( CASQueueStruc *Q ); | |
| 78 void writeCASQ( void *in, CASQueueStruc *Q ); | |
| 79 | |
| 80 | |
| 81 //========= non-atomic instr based queue =========== | |
| 82 typedef | |
| 83 struct | |
| 84 { void* *insertPos; | |
| 85 void* *extractPos; | |
| 86 void* startOfData[1024]; //data is pointers | |
| 87 void* *endOfData; //set when make queue | |
| 88 } | |
| 89 SRSWQueueStruc; | |
| 90 | |
| 91 SRSWQueueStruc* makeSRSWQ(); | |
| 92 void freeSRSWQ( SRSWQueueStruc* Q ); | |
| 93 void* readSRSWQ( SRSWQueueStruc *Q ); | |
| 94 void writeSRSWQ( void *in, SRSWQueueStruc *Q ); | |
| 95 | |
| 96 | |
| 97 //========= non-atomic instr S R M W queue =========== | |
| 98 typedef | |
| 99 struct | |
| 100 { int32 lastQReadFrom; | |
| 101 int32 numInternalQs; | |
| 102 int32 internalQsSz; | |
| 103 SRSWQueueStruc* *internalQs; | |
| 104 } | |
| 105 SRMWQueueStruc; | |
| 106 | |
| 107 SRMWQueueStruc* makeSRMWQ(); | |
| 108 int addWriterToSRMWQ( SRMWQueueStruc *Q ); | |
| 109 void* readSRMWQ( SRMWQueueStruc *Q ); | |
| 110 void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID ); | |
| 111 | |
| 112 | |
| 113 #endif /* _PRIVATE_QUEUE_H */ | |
| 114 |
