aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-07-18 07:17:44 +0000
committerMike Buland <eichlan@xagasoft.com>2012-07-18 07:17:44 +0000
commita10cdf5cbcfc11e948f2e64e3adb4325f96f6bb4 (patch)
treea0b44a2aaed09d248be3fc50ff42195b520de83a /src/stable
parent364ded646ad4de2065cdf0a2f4282c7eaf7148e6 (diff)
downloadlibbu++-a10cdf5cbcfc11e948f2e64e3adb4325f96f6bb4.tar.gz
libbu++-a10cdf5cbcfc11e948f2e64e3adb4325f96f6bb4.tar.bz2
libbu++-a10cdf5cbcfc11e948f2e64e3adb4325f96f6bb4.tar.xz
libbu++-a10cdf5cbcfc11e948f2e64e3adb4325f96f6bb4.zip
Fixed an issue in the seldomly used dequeue( bool ) function in
Bu::SynchroQueue and also added the unblockAll function, which makes the forever-blocking dequeue function suddenly much more useful.
Diffstat (limited to '')
-rw-r--r--src/stable/synchroqueue.h29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/stable/synchroqueue.h b/src/stable/synchroqueue.h
index 7ba299f..1c16e15 100644
--- a/src/stable/synchroqueue.h
+++ b/src/stable/synchroqueue.h
@@ -124,23 +124,25 @@ namespace Bu
124 { 124 {
125 if( bBlock ) 125 if( bBlock )
126 { 126 {
127 for(;;) 127 cBlock.wait();
128
129 if( pStart == NULL )
128 { 130 {
129 if( pStart != NULL ) 131 cBlock.unlock();
130 { 132 return NULL;
131 cBlock.unlock();
132 break;
133 }
134 cBlock.wait();
135 } 133 }
136 134 T pTmp = pStart->pData;
137 T tmp = dequeue( false ); 135 Item *pDel = pStart;
136 pStart = pStart->pNext;
137 delete pDel;
138 nSize--;
138 139
139 cBlock.unlock(); 140 cBlock.unlock();
140 return tmp; 141 return pTmp;
141 142
142 } 143 }
143 144
145 cBlock.unlock();
144 return NULL; 146 return NULL;
145 } 147 }
146 else 148 else
@@ -226,6 +228,13 @@ namespace Bu
226 return nRet; 228 return nRet;
227 } 229 }
228 230
231 void unblockAll()
232 {
233 cBlock.lock();
234 cBlock.broadcast();
235 cBlock.unlock();
236 }
237
229 private: 238 private:
230 Item *pStart; /**< The start of the queue, the next element to dequeue. */ 239 Item *pStart; /**< The start of the queue, the next element to dequeue. */
231 Item *pEnd; /**< The end of the queue, the last element to dequeue. */ 240 Item *pEnd; /**< The end of the queue, the last element to dequeue. */