SharedQueue.st
changeset 647 f937d30a8afc
parent 487 0230ee378075
child 845 39e962f58eb3
--- a/SharedQueue.st	Wed May 20 15:30:30 1998 +0200
+++ b/SharedQueue.st	Thu May 21 12:52:49 1998 +0200
@@ -124,6 +124,25 @@
     "Modified: 16.12.1995 / 13:47:11 / cg"
 !
 
+removeAll
+    "remove all elements in the queue; do not wait, but
+     synchronize access to the queue.
+     If the queue was full before, signal space-availability to writers.
+     This can be used to flush queues in multi-process applications,
+     when cleanup is required."
+
+    accessProtect critical:[
+        |oldCount|
+
+        oldCount := tally.
+        super removeAll.
+        oldCount == (contentsArray size) ifTrue:[
+            spaceAvailable signal
+        ].
+    ].
+
+!
+
 removeLast
     "return the last value in the queue; if it its empty, wait 'til
      something is put into the receiver.
@@ -181,5 +200,5 @@
 !SharedQueue class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/SharedQueue.st,v 1.19 1997-01-24 23:19:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/SharedQueue.st,v 1.20 1998-05-21 10:52:49 ca Exp $'
 ! !