annotate 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
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
seanhalle@31 8 #ifndef _BLOCKINGQUEUE_H
Me@5 9 #define _BLOCKINGQUEUE_H
Me@5 10
seanhalle@47 11 #include "PR__application_includes/PR__application.h"
Me@5 12
Me@5 13
Me@5 14 #define TRUE 1
Me@5 15 #define FALSE 0
Me@5 16
Me@5 17 #define LOCKED 1
Me@5 18 #define UNLOCKED 0
Me@5 19
Me@5 20
Me@5 21 //========== pThreads based queue ==========
Me@5 22 /* It is the data that is shared so only need one mutex. */
Me@5 23 typedef
Me@5 24 struct
Me@5 25 { pthread_mutex_t mutex_t;
Me@5 26 pthread_cond_t cond_w_t;
Me@5 27 pthread_cond_t cond_r_t;
seanhalle@44 28 int32 count;
seanhalle@44 29 int32 readPos;
seanhalle@44 30 int32 writePos;
Me@5 31 void* data[1024]; //an array of pointers
Me@5 32 int w_empty;
Me@5 33 int w_full;
Me@5 34 }
Me@5 35 PThdQueueStruc;
Me@5 36
Me@5 37 PThdQueueStruc* makePThdQ();
Me@5 38 void* readPThdQ( PThdQueueStruc *Q );
Me@5 39 void writePThdQ( void *in, PThdQueueStruc *Q );
Me@5 40
Me@5 41
Me@5 42 //========== CAS based queue ==========
Me@5 43 typedef
Me@5 44 struct
seanhalle@44 45 { volatile int32 insertLock;
seanhalle@44 46 volatile int32 extractLock;
Me@5 47 volatile void* *insertPos;
Me@5 48 volatile void* *extractPos;
Me@5 49 void* startOfData[1024]; //data is pointers
Me@5 50 void* *endOfData; //set when make queue
Me@5 51 }
Me@5 52 CASQueueStruc;
Me@5 53
Me@5 54 CASQueueStruc* makeCASQ();
Me@5 55 void* readCASQ( CASQueueStruc *Q );
Me@5 56 void writeCASQ( void *in, CASQueueStruc *Q );
Me@5 57
Me@5 58
Me@5 59 //========= non-atomic instr based queue ===========
Me@5 60 typedef
Me@5 61 struct
Me@5 62 { void* *insertPos;
Me@5 63 void* *extractPos;
Me@5 64 void* startOfData[1024]; //data is pointers
Me@5 65 void* *endOfData; //set when make queue
Me@5 66 }
Me@5 67 SRSWQueueStruc;
Me@5 68
Me@5 69 SRSWQueueStruc* makeSRSWQ();
Me@7 70 void freeSRSWQ( SRSWQueueStruc* Q );
Me@5 71 void* readSRSWQ( SRSWQueueStruc *Q );
Me@7 72 void writeSRSWQ( void *in, SRSWQueueStruc *Q );
Me@5 73
Me@5 74
Me@5 75 //========= non-atomic instr S R M W queue ===========
Me@5 76 typedef
Me@5 77 struct
seanhalle@44 78 { int32 lastQReadFrom;
seanhalle@44 79 int32 numInternalQs;
seanhalle@44 80 int32 internalQsSz;
Me@5 81 SRSWQueueStruc* *internalQs;
Me@5 82 }
Me@5 83 SRMWQueueStruc;
Me@5 84
Me@5 85 SRMWQueueStruc* makeSRMWQ();
Me@5 86 int addWriterToSRMWQ( SRMWQueueStruc *Q );
Me@5 87 void* readSRMWQ( SRMWQueueStruc *Q );
Me@5 88 void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID );
Me@5 89
Me@5 90
Me@5 91 #endif /* _BLOCKINGQUEUE_H */
Me@5 92