Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Queue_impl
changeset 44:67c7f5a0308b Renamed_VMS_to_PR
Renamed VMS to PR, in new branch
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Fri, 08 Mar 2013 05:40:08 -0800 |
| parents | d01d48b023ca |
| children | 8c0dcf6e15e6 |
| files | BlockingQueue.c BlockingQueue.h PrivateQueue.c PrivateQueue.h |
| diffstat | 4 files changed, 32 insertions(+), 27 deletions(-) [+] |
line diff
1.1 --- a/BlockingQueue.c Mon Sep 03 15:07:45 2012 -0700 1.2 +++ b/BlockingQueue.c Fri Mar 08 05:40:08 2013 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 1.6 + * Copyright 2009 OpenSourceResearchInstitute.org 1.7 * Licensed under GNU General Public License version 2 1.8 * 1.9 * Author: seanhalle@yahoo.com 1.10 @@ -50,11 +50,11 @@ 1.11 1.12 void* readCASQ( CASQueueStruc* Q ) 1.13 { void *out = 0; 1.14 - int tries = 0; 1.15 + int32 tries = 0; 1.16 void **startOfData = Q->startOfData; 1.17 void **endOfData = Q->endOfData; 1.18 1.19 - int gotLock = FALSE; 1.20 + int32 gotLock = FALSE; 1.21 1.22 while( TRUE ) 1.23 { //this intrinsic returns true if the lock held "UNLOCKED", in which 1.24 @@ -94,13 +94,13 @@ 1.25 1.26 void writeCASQ( void * in, CASQueueStruc* Q ) 1.27 { 1.28 - int tries = 0; 1.29 + int32 tries = 0; 1.30 //TODO: need to make Q volatile? Want to do this Q in assembly! 1.31 //Have no idea what GCC's going to do to this code 1.32 void **startOfData = Q->startOfData; 1.33 void **endOfData = Q->endOfData; 1.34 1.35 - int gotLock = FALSE; 1.36 + int32 gotLock = FALSE; 1.37 1.38 while( TRUE ) 1.39 { //this intrinsic returns true if the lock held "UNLOCKED", in which 1.40 @@ -178,7 +178,7 @@ 1.41 1.42 void* readSRSWQ( SRSWQueueStruc* Q ) 1.43 { void *out = 0; 1.44 - int tries = 0; 1.45 + int32 tries = 0; 1.46 1.47 while( TRUE ) 1.48 { 1.49 @@ -198,7 +198,7 @@ 1.50 1.51 void* readSRSWQ_NonBlocking( SRSWQueueStruc* Q ) 1.52 { void *out = 0; 1.53 - int tries = 0; 1.54 + int32 tries = 0; 1.55 1.56 while( TRUE ) 1.57 { 1.58 @@ -218,7 +218,7 @@ 1.59 1.60 void writeSRSWQ( void * in, SRSWQueueStruc* Q ) 1.61 { 1.62 - int tries = 0; 1.63 + int32 tries = 0; 1.64 1.65 while( TRUE ) 1.66 { 1.67 @@ -350,8 +350,8 @@ 1.68 void* readSRMWQ( SRMWQueueStruc* Q ) 1.69 { SRSWQueueStruc *readQ; 1.70 void *readValue = 0; 1.71 - int tries = 0; 1.72 - int QToReadFrom = 0; 1.73 + int32 tries = 0; 1.74 + int32 QToReadFrom = 0; 1.75 1.76 QToReadFrom = Q->lastQReadFrom; 1.77
2.1 --- a/BlockingQueue.h Mon Sep 03 15:07:45 2012 -0700 2.2 +++ b/BlockingQueue.h Fri Mar 08 05:40:08 2013 -0800 2.3 @@ -26,9 +26,9 @@ 2.4 { pthread_mutex_t mutex_t; 2.5 pthread_cond_t cond_w_t; 2.6 pthread_cond_t cond_r_t; 2.7 - int count; 2.8 - int readPos; 2.9 - int writePos; 2.10 + int32 count; 2.11 + int32 readPos; 2.12 + int32 writePos; 2.13 void* data[1024]; //an array of pointers 2.14 int w_empty; 2.15 int w_full; 2.16 @@ -43,8 +43,8 @@ 2.17 //========== CAS based queue ========== 2.18 typedef 2.19 struct 2.20 - { volatile int insertLock; 2.21 - volatile int extractLock; 2.22 + { volatile int32 insertLock; 2.23 + volatile int32 extractLock; 2.24 volatile void* *insertPos; 2.25 volatile void* *extractPos; 2.26 void* startOfData[1024]; //data is pointers 2.27 @@ -76,9 +76,9 @@ 2.28 //========= non-atomic instr S R M W queue =========== 2.29 typedef 2.30 struct 2.31 - { int lastQReadFrom; 2.32 - int numInternalQs; 2.33 - int internalQsSz; 2.34 + { int32 lastQReadFrom; 2.35 + int32 numInternalQs; 2.36 + int32 internalQsSz; 2.37 SRSWQueueStruc* *internalQs; 2.38 } 2.39 SRMWQueueStruc;
3.1 --- a/PrivateQueue.c Mon Sep 03 15:07:45 2012 -0700 3.2 +++ b/PrivateQueue.c Fri Mar 08 05:40:08 2013 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 3.6 + * Copyright 2009 OpenSourceResearchInstitute.org 3.7 * Licensed under GNU General Public License version 2 3.8 * 3.9 * NOTE: this version of SRSW correct as of April 25, 2010 3.10 @@ -40,6 +40,9 @@ 3.11 } 3.12 3.13 3.14 +/*A bit tricky, 'cause have to copy in two halves, and be careful about case 3.15 + * when insert is at top and extract at bottom.. 3.16 + */ 3.17 void 3.18 enlargePrivQ( PrivQueueStruc *Q ) 3.19 { int32 oldSize, newSize, topPartSize, bottPartSize; 3.20 @@ -283,10 +286,12 @@ 3.21 } 3.22 3.23 3.24 - void 3.25 - freePrivQ( PrivQueueStruc *Q ) 3.26 - { 3.27 - //This free is not safe to use in wrapper lib nor app code! 3.28 - PR_int__free( Q->startOfData ); 3.29 - PR_int__free( Q ); 3.30 - } 3.31 \ No newline at end of file 3.32 +/*NOTE: This free is not safe to use in wrapper lib nor app code 3.33 + */ 3.34 +void 3.35 +freePrivQ( PrivQueueStruc *Q ) 3.36 + { 3.37 + //This free is not safe to use in wrapper lib nor app code! 3.38 + PR_int__free( Q->startOfData ); 3.39 + PR_int__free( Q ); 3.40 + }
4.1 --- a/PrivateQueue.h Mon Sep 03 15:07:45 2012 -0700 4.2 +++ b/PrivateQueue.h Fri Mar 08 05:40:08 2013 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 4.6 + * Copyright 2009 OpenSourceResearchInstitute.org 4.7 * Licensed under GNU General Public License version 2 4.8 * 4.9 * Author: seanhalle@yahoo.com
