comparison PrivateQueue.c @ 11:3562716ebdbd

added numInPrivQ service
author Me
date Thu, 04 Nov 2010 17:54:08 -0700
parents 62326cc8e6f4
children 3134d8a1e8e3 447e97a52426
comparison
equal deleted inserted replaced
4:fb1b528ea28b 5:ae4ea439d8dd
1 /* 1 /*
2 * Copyright 2009 OpenSourceStewardshipFoundation.org 2 * Copyright 2009 OpenSourceStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2 3 * Licensed under GNU General Public License version 2
4 *
5 * NOTE: this version of SRSW correct as of April 25, 2010
6 * 4 *
7 * Author: seanhalle@yahoo.com 5 * Author: seanhalle@yahoo.com
8 */ 6 */
9 7
10 8
81 } 79 }
82 //Q is empty 80 //Q is empty
83 return NULL; 81 return NULL;
84 } 82 }
85 83
84 int32
85 numInPrivQ( PrivQueueStruc *Q )
86 { int32 size, numIn;
87
88 if( Q->insertPos < Q->extractPos )
89 { //insert has wrapped around so numIn is:
90 // insertPos + size - extractPos -- Consider, is empty when
91 // extractPos = endOfData and insert = start -- correctly get zero
92 size = Q->endOfData - Q->startOfData;
93 numIn = Q->insertPos + size - Q->extractPos;
94 }
95 else
96 {
97 numIn = Q->insertPos - Q->extractPos -1;//-1 bec empty @ side-by-side
98 }
99 return numIn;
100 }
101
86 102
87 /*Expands the queue size automatically when it's full 103 /*Expands the queue size automatically when it's full
88 */ 104 */
89 void 105 void
90 writePrivQ( void * in, PrivQueueStruc* Q ) 106 writePrivQ( void * in, PrivQueueStruc* Q )