#DOCUMENTATION by cg
authorClaus Gittinger <cg@exept.de>
Wed, 07 Sep 2016 15:27:45 +0200
changeset 4066 405375f4f7de
parent 4065 9eb6ea6224d9
child 4067 b462a3ff3a61
#DOCUMENTATION by cg class: SharedQueue category of:10 methods
SharedQueue.st
--- a/SharedQueue.st	Wed Sep 07 15:26:24 2016 +0200
+++ b/SharedQueue.st	Wed Sep 07 15:27:45 2016 +0200
@@ -123,118 +123,6 @@
 
 !SharedQueue methodsFor:'accessing'!
 
-do:anObject
-    "evaluate the argument, aBlock for each element in the queue"
-
-    |retVal|
-
-    accessLock critical:[
-        retVal := super do:anObject.
-    ].
-    ^ retVal.
-!
-
-next
-    "return the next 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"
-
-    |retVal|
-
-    dataAvailable wait.
-    accessLock critical:[
-        retVal := super nextOrNil.
-    ].
-    spaceAvailable signal.
-
-    ^ retVal.
-!
-
-nextIfEmpty:exceptionValue
-    "return the next value in the queue; if it its empty do not wait, but return
-     the value of exceptionValue.
-     When a datum has been removed, signal space-availability to writers"
-
-    |retVal anyRemoved|
-
-    accessLock critical:[
-        self isEmpty ifTrue:[
-            retVal := exceptionValue value
-        ] ifFalse:[
-            retVal := super nextOrNil.
-            anyRemoved := true.
-        ].
-    ].
-    anyRemoved == true ifTrue:[spaceAvailable signal].
-
-    ^ retVal.
-!
-
-nextOrNil
-    ^ self nextIfEmpty:nil
-
-    "Created: / 31-05-2007 / 15:09:33 / cg"
-!
-
-nextPut:anObject
-    "enter anObject to the end of the queue; 
-     wait for available space, if the queue is full. 
-     After the put, signal availablity of a datum to readers."
-
-    |retVal|
-
-    spaceAvailable wait.
-    accessLock critical:[
-        retVal := super nextPut:anObject.
-        dataAvailable signal.
-    ].
-    ^ retVal.
-!
-
-nextPutFirst:anObject
-    "insert anObject at the beginning of the queue; 
-     wait for available space, if the queue is full. 
-     After the put, signal availablity of a datum to readers.
-     Insertion at the beginning may be useful to add hi-prio elements (for example, in a job-scheduler)"
-
-    |retVal|
-
-    spaceAvailable wait.
-    accessLock critical:[
-        retVal := super nextPutFirst:anObject.
-        dataAvailable signal.
-    ].
-    ^ retVal.
-!
-
-nextWithTimeout:seconds
-    "return the next value in the queue; if it its empty, wait until
-     something is put into the receiver.
-     When the datum has been removed, signal space-availability to
-     writers.
-     Timeout after secondsIn seconds - answer nil if a timeout occurs."
-
-    |retVal|
-
-    (dataAvailable waitWithTimeout:seconds) isNil ifTrue:[
-        ^ nil
-    ].
-    accessLock critical:[
-        retVal := super nextOrNil.
-    ].
-    spaceAvailable signal.
-
-    ^ retVal.
-!
-
-peek
-    self isEmpty ifTrue:[
-        dataAvailable waitUncounted.
-    ].
-    ^ super peek
-!
-
 removeAll
     "remove all elements in the queue; do not wait, but
      synchronize access to the queue.
@@ -283,18 +171,6 @@
     spaceAvailable signal.
 
     ^ retVal.
-!
-
-superNextPut:anObject
-    "private; to allow subclasses to call the basic nextPut (w.o. synchronization)"
-
-    ^ super nextPut:anObject.
-!
-
-superNextPutFirst:anObject
-    "private; to allow subclasses to call the basic nextPutFirst (w.o. synchronization)"
-
-    ^ super nextPutFirst:anObject.
 ! !
 
 !SharedQueue methodsFor:'accessing-internals'!
@@ -320,6 +196,18 @@
     ^ (dataAvailable waitUncountedWithTimeoutMs:ms) isNil.
 !
 
+superNextPut:anObject
+    "private; to allow subclasses to call the basic nextPut (w.o. synchronization)"
+
+    ^ super nextPut:anObject.
+!
+
+superNextPutFirst:anObject
+    "private; to allow subclasses to call the basic nextPutFirst (w.o. synchronization)"
+
+    ^ super nextPutFirst:anObject.
+!
+
 withAccessLockedDo:aBlock
     "evaluate aBlock while access via next/nextPut are blocked."
 
@@ -335,6 +223,124 @@
     "Modified: 16.12.1995 / 13:47:07 / cg"
 ! !
 
+!SharedQueue methodsFor:'accessing-reading'!
+
+next
+    "return the next 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"
+
+    |retVal|
+
+    dataAvailable wait.
+    accessLock critical:[
+        retVal := super nextOrNil.
+    ].
+    spaceAvailable signal.
+
+    ^ retVal.
+!
+
+nextIfEmpty:exceptionValue
+    "return the next value in the queue; if it its empty do not wait, but return
+     the value of exceptionValue.
+     When a datum has been removed, signal space-availability to writers"
+
+    |retVal anyRemoved|
+
+    accessLock critical:[
+        self isEmpty ifTrue:[
+            retVal := exceptionValue value
+        ] ifFalse:[
+            retVal := super nextOrNil.
+            anyRemoved := true.
+        ].
+    ].
+    anyRemoved == true ifTrue:[spaceAvailable signal].
+
+    ^ retVal.
+!
+
+nextOrNil
+    ^ self nextIfEmpty:nil
+
+    "Created: / 31-05-2007 / 15:09:33 / cg"
+!
+
+nextWithTimeout:seconds
+    "return the next value in the queue; if it its empty, wait until
+     something is put into the receiver.
+     When the datum has been removed, signal space-availability to
+     writers.
+     Timeout after secondsIn seconds - answer nil if a timeout occurs."
+
+    |retVal|
+
+    (dataAvailable waitWithTimeout:seconds) isNil ifTrue:[
+        ^ nil
+    ].
+    accessLock critical:[
+        retVal := super nextOrNil.
+    ].
+    spaceAvailable signal.
+
+    ^ retVal.
+!
+
+peek
+    self isEmpty ifTrue:[
+        dataAvailable waitUncounted.
+    ].
+    ^ super peek
+! !
+
+!SharedQueue methodsFor:'accessing-writing'!
+
+nextPut:anObject
+    "enter anObject to the end of the queue; 
+     wait for available space, if the queue is full. 
+     After the put, signal availablity of a datum to readers."
+
+    |retVal|
+
+    spaceAvailable wait.
+    accessLock critical:[
+        retVal := super nextPut:anObject.
+        dataAvailable signal.
+    ].
+    ^ retVal.
+!
+
+nextPutFirst:anObject
+    "insert anObject at the beginning of the queue; 
+     wait for available space, if the queue is full. 
+     After the put, signal availablity of a datum to readers.
+     Insertion at the beginning may be useful to add hi-prio elements (for example, in a job-scheduler)"
+
+    |retVal|
+
+    spaceAvailable wait.
+    accessLock critical:[
+        retVal := super nextPutFirst:anObject.
+        dataAvailable signal.
+    ].
+    ^ retVal.
+! !
+
+!SharedQueue methodsFor:'enumerating'!
+
+do:anObject
+    "evaluate the argument, aBlock for each element in the queue"
+
+    |retVal|
+
+    accessLock critical:[
+        retVal := super do:anObject.
+    ].
+    ^ retVal.
+! !
+
 !SharedQueue methodsFor:'initialization'!
 
 init:size