Fix in #waitUntilProcessed
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 13 Dec 2011 15:16:02 +0100
changeset 2697 0090025b8aa7
parent 2696 689bb9231455
child 2698 16c85264fef2
Fix in #waitUntilProcessed
BackgroundQueueProcessingJob.st
--- a/BackgroundQueueProcessingJob.st	Tue Dec 06 19:03:05 2011 +0100
+++ b/BackgroundQueueProcessingJob.st	Tue Dec 13 15:16:02 2011 +0100
@@ -198,10 +198,16 @@
 waitUntilProcessed
     "Blocks the receiver until all items from the queue are processed.
     NOTE, that it may block forever if another thread is filling queue
-    fadt enough."
+    fast enough."
 
-    self scheduled ifFalse:[ ^ self ].
-    queueProcessedSema wait.
+    | shouldWait |        
+    queueAccessLock critical:[
+        shouldWait := queue isEmpty.
+    ].
+    shouldWait ifTrue:[
+        self start.
+        queueProcessedSema wait.
+    ]
 
     "
     queueProcessedSema signalForAll    
@@ -213,11 +219,11 @@
 !BackgroundQueueProcessingJob class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/BackgroundQueueProcessingJob.st,v 1.10 2011-12-06 18:03:05 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/BackgroundQueueProcessingJob.st,v 1.11 2011-12-13 14:16:02 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/BackgroundQueueProcessingJob.st,v 1.10 2011-12-06 18:03:05 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/BackgroundQueueProcessingJob.st,v 1.11 2011-12-13 14:16:02 vrany Exp $'
 !
 
 version_SVN