Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Queue_impl
diff BlockingQueue.c @ 49:083298a6f7b6
new branch PR_univ_lib -- creates a static library, copied to /usr/lib/PR__lib
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Sat, 27 Jul 2013 13:10:10 -0700 |
| parents | 1ea30ca7093c |
| children |
line diff
1.1 --- a/BlockingQueue.c Tue Jul 23 07:28:22 2013 -0700 1.2 +++ b/BlockingQueue.c Sat Jul 27 13:10:10 2013 -0700 1.3 @@ -14,13 +14,32 @@ 1.4 #include <string.h> 1.5 1.6 #include "BlockingQueue.h" 1.7 -#include "PR__common_includes/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h" 1.8 +#include <PR__include/prqueue.h> 1.9 +#include <PR__include/prmalloc.h> 1.10 1.11 #define INC(x) (++x == 1024) ? (x) = 0 : (x) 1.12 1.13 #define SPINLOCK_TRIES 100000 1.14 1.15 1.16 +//========================== pthread based queue ========================= 1.17 +/*Not currently implemented.. however, copied this code from place where 1.18 + * did equivalent.. Idea is to just make a private queue, then protect 1.19 + * access with a lock.. copied code snippet below is how access was 1.20 + * protected.. just roll this inside a "readBlockingQ()" function.. do 1.21 + * equivalent inside writeBlockingQ() function.. to make one, just add 1.22 + * the lock to the queue structure.. 1.23 + */ 1.24 +/* 1.25 + production = NULL; 1.26 + while( production == NULL ) 1.27 + { pthread_mutex_lock( &queueAccessLock ); 1.28 + production = readPrivQ( commQ ); 1.29 + pthread_mutex_unlock( &queueAccessLock ); 1.30 + // If empty, yields and tries again. 1.31 + if( production == NULL) sched_yield(); 1.32 + } 1.33 +*/ 1.34 1.35 //=========================================================================== 1.36 // multi reader multi writer fast Q via CAS 1.37 @@ -36,7 +55,7 @@ 1.38 CASQueueStruc* makeCASQ() 1.39 { 1.40 CASQueueStruc* retQ; 1.41 - retQ = (CASQueueStruc *) PR_WL__malloc( sizeof( CASQueueStruc ) ); 1.42 + retQ = (CASQueueStruc *) PR__malloc( sizeof( CASQueueStruc ) ); 1.43 1.44 retQ->insertLock = UNLOCKED; 1.45 retQ->extractLock= UNLOCKED; 1.46 @@ -161,7 +180,7 @@ 1.47 SRSWQueueStruc* makeSRSWQ() 1.48 { 1.49 SRSWQueueStruc* retQ; 1.50 - retQ = (SRSWQueueStruc *) PR_WL__malloc( sizeof( SRSWQueueStruc ) ); 1.51 + retQ = (SRSWQueueStruc *) PR__malloc( sizeof( SRSWQueueStruc ) ); 1.52 memset( retQ->startOfData, 0, 1024 * sizeof(void *) ); 1.53 1.54 retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty 1.55 @@ -300,11 +319,11 @@ 1.56 SRMWQueueStruc* makeSRMWQ() 1.57 { SRMWQueueStruc* retQ; 1.58 1.59 - retQ = (SRMWQueueStruc *) PR_WL__malloc( sizeof( SRMWQueueStruc ) ); 1.60 + retQ = (SRMWQueueStruc *) PR__malloc( sizeof( SRMWQueueStruc ) ); 1.61 1.62 retQ->numInternalQs = 0; 1.63 retQ->internalQsSz = 10; 1.64 - retQ->internalQs = PR_WL__malloc( retQ->internalQsSz * sizeof(SRSWQueueStruc *)); 1.65 + retQ->internalQs = PR__malloc( retQ->internalQsSz * sizeof(SRSWQueueStruc *)); 1.66 1.67 retQ->lastQReadFrom = 0; 1.68 1.69 @@ -330,7 +349,7 @@ 1.70 oldSz = Q->internalQsSz; 1.71 oldArray = Q->internalQs; 1.72 Q->internalQsSz *= 2; 1.73 - Q->internalQs = PR_WL__malloc( Q->internalQsSz * sizeof(SRSWQueueStruc *)); 1.74 + Q->internalQs = PR__malloc( Q->internalQsSz * sizeof(SRSWQueueStruc *)); 1.75 for( i = 0; i < oldSz; i++ ) 1.76 { Q->internalQs[i] = oldArray[i]; 1.77 }
