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