annotate BlockingQueue.h @ 28:dabefab7d264

fixed include paths -- paths should be set in Netbeans as project settings
author Some Random Person <seanhalle@yahoo.com>
date Fri, 09 Mar 2012 22:12:01 -0800
parents 08f0b4da7610
children 555cc068a79a
rev   line source
Me@5 1 /*
Me@5 2 * File: BlockingQueue.h
Me@5 3 * Author: SeanHalle@yahoo.com
Me@5 4 *
Me@5 5 * Created on November 11, 2009, 12:51 PM
Me@5 6 */
Me@5 7
Me@5 8 #ifndef _BLOCKINGQUEUE_H
Me@5 9 #define _BLOCKINGQUEUE_H
Me@5 10
Me@20 11 #include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h"
Me@20 12 #include "../../VMS_Implementations/VMS_impl/vmalloc.h"
Me@5 13
Me@5 14
Me@5 15 #define TRUE 1
Me@5 16 #define FALSE 0
Me@5 17
Me@5 18 #define LOCKED 1
Me@5 19 #define UNLOCKED 0
Me@5 20
Me@5 21
Me@5 22 //========== pThreads based queue ==========
Me@5 23 /* It is the data that is shared so only need one mutex. */
Me@5 24 typedef
Me@5 25 struct
Me@5 26 { pthread_mutex_t mutex_t;
Me@5 27 pthread_cond_t cond_w_t;
Me@5 28 pthread_cond_t cond_r_t;
Me@5 29 int count;
Me@5 30 int readPos;
Me@5 31 int writePos;
Me@5 32 void* data[1024]; //an array of pointers
Me@5 33 int w_empty;
Me@5 34 int w_full;
Me@5 35 }
Me@5 36 PThdQueueStruc;
Me@5 37
Me@5 38 PThdQueueStruc* makePThdQ();
Me@5 39 void* readPThdQ( PThdQueueStruc *Q );
Me@5 40 void writePThdQ( void *in, PThdQueueStruc *Q );
Me@5 41
Me@5 42
Me@5 43 //========== CAS based queue ==========
Me@5 44 typedef
Me@5 45 struct
Me@5 46 { volatile int insertLock;
Me@5 47 volatile int extractLock;
Me@5 48 volatile void* *insertPos;
Me@5 49 volatile void* *extractPos;
Me@5 50 void* startOfData[1024]; //data is pointers
Me@5 51 void* *endOfData; //set when make queue
Me@5 52 }
Me@5 53 CASQueueStruc;
Me@5 54
Me@5 55 CASQueueStruc* makeCASQ();
Me@5 56 void* readCASQ( CASQueueStruc *Q );
Me@5 57 void writeCASQ( void *in, CASQueueStruc *Q );
Me@5 58
Me@5 59
Me@5 60 //========= non-atomic instr based queue ===========
Me@5 61 typedef
Me@5 62 struct
Me@5 63 { void* *insertPos;
Me@5 64 void* *extractPos;
Me@5 65 void* startOfData[1024]; //data is pointers
Me@5 66 void* *endOfData; //set when make queue
Me@5 67 }
Me@5 68 SRSWQueueStruc;
Me@5 69
Me@5 70 SRSWQueueStruc* makeSRSWQ();
Me@7 71 void freeSRSWQ( SRSWQueueStruc* Q );
Me@5 72 void* readSRSWQ( SRSWQueueStruc *Q );
Me@7 73 void writeSRSWQ( void *in, SRSWQueueStruc *Q );
Me@5 74
Me@5 75
Me@5 76 //========= non-atomic instr S R M W queue ===========
Me@5 77 typedef
Me@5 78 struct
Me@5 79 { int lastQReadFrom;
Me@5 80 int numInternalQs;
Me@5 81 int internalQsSz;
Me@5 82 SRSWQueueStruc* *internalQs;
Me@5 83 }
Me@5 84 SRMWQueueStruc;
Me@5 85
Me@5 86 SRMWQueueStruc* makeSRMWQ();
Me@5 87 int addWriterToSRMWQ( SRMWQueueStruc *Q );
Me@5 88 void* readSRMWQ( SRMWQueueStruc *Q );
Me@5 89 void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID );
Me@5 90
Me@5 91
Me@5 92 #endif /* _BLOCKINGQUEUE_H */
Me@5 93