SharedQueue.st
changeset 396 88bd6136ee67
parent 257 759055770356
child 469 9b4318b56d9d
--- a/SharedQueue.st	Wed Jun 12 13:35:16 1996 +0200
+++ b/SharedQueue.st	Sat Jun 22 18:52:25 1996 +0200
@@ -17,7 +17,7 @@
 	category:'Kernel-Processes'
 !
 
-!SharedQueue class methodsFor:'documentation'!
+!SharedQueue  class methodsFor:'documentation'!
 
 copyright
 "
@@ -123,6 +123,38 @@
     "Modified: 16.12.1995 / 13:47:11 / cg"
 !
 
+removeLast
+    "return the last value in the queue; if it its empty, wait 'til
+     something is put into the receiver.
+     When the datum has been removed, signal space-availability to
+     writers"
+
+    |value ok|
+
+    ok := false.
+    [ok] whileFalse:[
+        [tally == 0] whileTrue:[
+            dataAvailable wait
+        ].
+        accessProtect critical:[
+            "
+             this check is needed, since another process may
+             have read the value in the meantime ...
+            "
+            tally == 0 ifFalse:[
+                value := super removeLast.
+                tally == (contentsArray size - 1) ifTrue:[
+                    spaceAvailable signal
+                ].
+                ok := true
+            ]
+        ]
+    ].
+    ^ value
+
+    "Created: 22.6.1996 / 18:50:12 / cg"
+!
+
 writeSemaphore
     "return the semaphore which is signalled when the queue has space
      for writing."
@@ -143,8 +175,8 @@
     spaceAvailable := Semaphore new
 ! !
 
-!SharedQueue class methodsFor:'documentation'!
+!SharedQueue  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/SharedQueue.st,v 1.15 1996-04-25 16:54:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/SharedQueue.st,v 1.16 1996-06-22 16:52:25 cg Exp $'
 ! !