Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Queue_impl
comparison BlockingQueue.c @ 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 | d01d48b023ca |
| children | 1ea30ca7093c |
comparison
equal
deleted
inserted
replaced
| 18:e21c9bb599b6 | 19:66886ded7002 |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2009 OpenSourceStewardshipFoundation.org | 2 * Copyright 2009 OpenSourceResearchInstitute.org |
| 3 * Licensed under GNU General Public License version 2 | 3 * Licensed under GNU General Public License version 2 |
| 4 * | 4 * |
| 5 * Author: seanhalle@yahoo.com | 5 * Author: seanhalle@yahoo.com |
| 6 */ | 6 */ |
| 7 | 7 |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 void* readCASQ( CASQueueStruc* Q ) | 51 void* readCASQ( CASQueueStruc* Q ) |
| 52 { void *out = 0; | 52 { void *out = 0; |
| 53 int tries = 0; | 53 int32 tries = 0; |
| 54 void **startOfData = Q->startOfData; | 54 void **startOfData = Q->startOfData; |
| 55 void **endOfData = Q->endOfData; | 55 void **endOfData = Q->endOfData; |
| 56 | 56 |
| 57 int gotLock = FALSE; | 57 int32 gotLock = FALSE; |
| 58 | 58 |
| 59 while( TRUE ) | 59 while( TRUE ) |
| 60 { //this intrinsic returns true if the lock held "UNLOCKED", in which | 60 { //this intrinsic returns true if the lock held "UNLOCKED", in which |
| 61 // case it now holds "LOCKED" -- if it already held "LOCKED", then | 61 // case it now holds "LOCKED" -- if it already held "LOCKED", then |
| 62 // gotLock is FALSE | 62 // gotLock is FALSE |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 void writeCASQ( void * in, CASQueueStruc* Q ) | 95 void writeCASQ( void * in, CASQueueStruc* Q ) |
| 96 { | 96 { |
| 97 int tries = 0; | 97 int32 tries = 0; |
| 98 //TODO: need to make Q volatile? Want to do this Q in assembly! | 98 //TODO: need to make Q volatile? Want to do this Q in assembly! |
| 99 //Have no idea what GCC's going to do to this code | 99 //Have no idea what GCC's going to do to this code |
| 100 void **startOfData = Q->startOfData; | 100 void **startOfData = Q->startOfData; |
| 101 void **endOfData = Q->endOfData; | 101 void **endOfData = Q->endOfData; |
| 102 | 102 |
| 103 int gotLock = FALSE; | 103 int32 gotLock = FALSE; |
| 104 | 104 |
| 105 while( TRUE ) | 105 while( TRUE ) |
| 106 { //this intrinsic returns true if the lock held "UNLOCKED", in which | 106 { //this intrinsic returns true if the lock held "UNLOCKED", in which |
| 107 // case it now holds "LOCKED" -- if it already held "LOCKED", then | 107 // case it now holds "LOCKED" -- if it already held "LOCKED", then |
| 108 // gotLock is FALSE | 108 // gotLock is FALSE |
| 176 PR_int__free( Q ); | 176 PR_int__free( Q ); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void* readSRSWQ( SRSWQueueStruc* Q ) | 179 void* readSRSWQ( SRSWQueueStruc* Q ) |
| 180 { void *out = 0; | 180 { void *out = 0; |
| 181 int tries = 0; | 181 int32 tries = 0; |
| 182 | 182 |
| 183 while( TRUE ) | 183 while( TRUE ) |
| 184 { | 184 { |
| 185 if( Q->insertPos - Q->extractPos != 1 && | 185 if( Q->insertPos - Q->extractPos != 1 && |
| 186 !(Q->extractPos == Q->endOfData && Q->insertPos == Q->startOfData)) | 186 !(Q->extractPos == Q->endOfData && Q->insertPos == Q->startOfData)) |
| 196 } | 196 } |
| 197 | 197 |
| 198 | 198 |
| 199 void* readSRSWQ_NonBlocking( SRSWQueueStruc* Q ) | 199 void* readSRSWQ_NonBlocking( SRSWQueueStruc* Q ) |
| 200 { void *out = 0; | 200 { void *out = 0; |
| 201 int tries = 0; | 201 int32 tries = 0; |
| 202 | 202 |
| 203 while( TRUE ) | 203 while( TRUE ) |
| 204 { | 204 { |
| 205 if( Q->insertPos - Q->extractPos != 1 && | 205 if( Q->insertPos - Q->extractPos != 1 && |
| 206 !(Q->extractPos == Q->endOfData && Q->insertPos == Q->startOfData)) | 206 !(Q->extractPos == Q->endOfData && Q->insertPos == Q->startOfData)) |
| 216 } | 216 } |
| 217 | 217 |
| 218 | 218 |
| 219 void writeSRSWQ( void * in, SRSWQueueStruc* Q ) | 219 void writeSRSWQ( void * in, SRSWQueueStruc* Q ) |
| 220 { | 220 { |
| 221 int tries = 0; | 221 int32 tries = 0; |
| 222 | 222 |
| 223 while( TRUE ) | 223 while( TRUE ) |
| 224 { | 224 { |
| 225 if( Q->extractPos - Q->insertPos != 1 && | 225 if( Q->extractPos - Q->insertPos != 1 && |
| 226 !(Q->insertPos == Q->endOfData && Q->extractPos == Q->startOfData)) | 226 !(Q->insertPos == Q->endOfData && Q->extractPos == Q->startOfData)) |
| 348 * ---]]] if got null from all the queues then does yield() then tries again | 348 * ---]]] if got null from all the queues then does yield() then tries again |
| 349 */ | 349 */ |
| 350 void* readSRMWQ( SRMWQueueStruc* Q ) | 350 void* readSRMWQ( SRMWQueueStruc* Q ) |
| 351 { SRSWQueueStruc *readQ; | 351 { SRSWQueueStruc *readQ; |
| 352 void *readValue = 0; | 352 void *readValue = 0; |
| 353 int tries = 0; | 353 int32 tries = 0; |
| 354 int QToReadFrom = 0; | 354 int32 QToReadFrom = 0; |
| 355 | 355 |
| 356 QToReadFrom = Q->lastQReadFrom; | 356 QToReadFrom = Q->lastQReadFrom; |
| 357 | 357 |
| 358 while( TRUE ) | 358 while( TRUE ) |
| 359 { QToReadFrom++; | 359 { QToReadFrom++; |
