#DOCUMENTATION by cg
authorClaus Gittinger <cg@exept.de>
Tue, 25 Jun 2019 14:28:51 +0200
changeset 5050 44fa8672d102
parent 5049 0d48cb487e0c
child 5051 44da029d521c
#DOCUMENTATION by cg class: SharedQueue comment/format in: #next #nextWithTimeout:
SharedQueue.st
--- a/SharedQueue.st	Tue Jun 25 14:22:47 2019 +0200
+++ b/SharedQueue.st	Tue Jun 25 14:28:51 2019 +0200
@@ -296,8 +296,7 @@
 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"
+     When the datum has been removed, signal space-availability to writers"
 
     |retVal|
 
@@ -312,7 +311,7 @@
     ^ retVal.
 
     "Modified: / 22-02-2017 / 14:40:32 / stefan"
-    "Modified (format): / 04-06-2019 / 21:06:53 / Claus Gittinger"
+    "Modified (comment): / 25-06-2019 / 14:28:44 / Claus Gittinger"
 !
 
 nextIfEmpty:exceptionBlock
@@ -350,15 +349,22 @@
     "Modified (comment): / 25-06-2019 / 14:22:33 / Claus Gittinger"
 !
 
-nextWithTimeout:seconds
+nextWithTimeout:secondsOrTimeDurationOrNil
     "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."
+     Answer nil if a timeout occurs.
+
+     The argument may be a time duration or the number of seconds as integer
+     or float (i.e. use 0.1 for a 100ms timeout).
+     With zero timeout, this can be used to poll a semaphore (returning
+     the receiver if the semaphore is available, nil if not).
+     However, polling is not the intended use of semaphores, though.
+     If the argument is nil, wait without timeout (forever)."
 
     |retVal|
 
-    (dataAvailable waitWithTimeout:seconds) isNil ifTrue:[
+    (dataAvailable waitWithTimeout:secondsOrTimeDurationOrNil) isNil ifTrue:[
         ^ nil
     ].
     retVal := accessLock critical:[super nextOrNil].
@@ -367,7 +373,7 @@
     ^ retVal.
 
     "Modified: / 22-02-2017 / 14:35:09 / stefan"
-    "Modified (comment): / 04-06-2019 / 21:13:01 / Claus Gittinger"
+    "Modified (format): / 25-06-2019 / 14:28:27 / Claus Gittinger"
 !
 
 peek