annotate BlockingQueue.h @ 0:85af604dee9b

initial add
author Me
date Sat, 22 May 2010 19:51:09 -0700
parents
children 228ca5487d81
rev   line source
Me@0 1 /*
Me@0 2 * Copyright 2009 OpenSourceStewardshipFoundation.org
Me@0 3 * Licensed under GNU General Public License version 2
Me@0 4 *
Me@0 5 * Author: seanhalle@yahoo.com
Me@0 6 */
Me@0 7
Me@0 8 #ifndef _BLOCKING_QUEUE_H
Me@0 9 #define _BLOCKING_QUEUE_H
Me@0 10
Me@0 11 #include <pthread.h>
Me@0 12
Me@0 13 #define TRUE 1
Me@0 14 #define FALSE 0
Me@0 15
Me@0 16 #define LOCKED 1
Me@0 17 #define UNLOCKED 0
Me@0 18
Me@0 19
Me@0 20 /* It is the data that is shared so only need one mutex. */
Me@0 21 typedef
Me@0 22 struct
Me@0 23 {
Me@0 24 pthread_mutex_t mutex_t;
Me@0 25 pthread_cond_t cond_w_t;
Me@0 26 pthread_cond_t cond_r_t;
Me@0 27 int count;
Me@0 28 int readPos;
Me@0 29 int writePos;
Me@0 30 void* data[1024]; //an array of pointers
Me@0 31 int w_empty;
Me@0 32 int w_full;
Me@0 33 }
Me@0 34 QueueStruc;
Me@0 35
Me@0 36
Me@0 37 typedef
Me@0 38 struct
Me@0 39 { int insertLock;
Me@0 40 int extractLock;
Me@0 41 void* *insertPos;
Me@0 42 void* *extractPos;
Me@0 43 void* startOfData[1024]; //data is pointers
Me@0 44 void* *endOfData; //set when make queue
Me@0 45 }
Me@0 46 CASQueueStruc;
Me@0 47
Me@0 48
Me@0 49 typedef
Me@0 50 struct
Me@0 51 { void* *insertPos;
Me@0 52 void* *extractPos;
Me@0 53 void* startOfData[1024]; //data is pointers
Me@0 54 void* *endOfData; //set when make queue
Me@0 55 }
Me@0 56 SRSWQueueStruc;
Me@0 57
Me@0 58
Me@0 59 QueueStruc* makeQ();
Me@0 60 void* readQ( QueueStruc *Q );
Me@0 61 void writeQ( void *in, QueueStruc *Q );
Me@0 62
Me@0 63 CASQueueStruc* makeCASQ();
Me@0 64 void* readCASQ( CASQueueStruc *Q );
Me@0 65 void writeCASQ( void *in, CASQueueStruc *Q );
Me@0 66
Me@0 67 SRSWQueueStruc* makeSRSWQ();
Me@0 68 void* readSRSWQ( SRSWQueueStruc *Q );
Me@0 69 void writeSRSWQ( void *in, SRSWQueueStruc *Q );
Me@0 70
Me@0 71 #endif /* _BLOCKING_QUEUE_H */
Me@0 72