protocol of waitWithTImeOut: changed
authorClaus Gittinger <cg@exept.de>
Sat, 16 Dec 1995 02:23:39 +0100
changeset 770 402958905760
parent 769 84cc1b36f27e
child 771 1ad3f852e201
protocol of waitWithTImeOut: changed
SemaSet.st
Semaphore.st
SemaphoreSet.st
--- a/SemaSet.st	Sat Dec 16 02:16:25 1995 +0100
+++ b/SemaSet.st	Sat Dec 16 02:23:39 1995 +0100
@@ -1,5 +1,3 @@
-'From Smalltalk/X, Version:2.10.8 on 15-dec-1995 at 23:16:48'                   !
-
 IdentitySet subclass:#SemaphoreSet
 	instanceVariableNames:''
 	classVariableNames:''
@@ -128,6 +126,9 @@
 !
 
 waitWithTimeout:seconds
+    "wait for any of the the semaphore, but abort the wait after some time.
+     Return the first triggered semaphore if any, nil if we return due to a timeout."
+
     |currentProcess gotSema wasBlocked now endTime unblock timeoutOccured registeredAllSemas|
 
     currentProcess := Processor activeProcess.
@@ -178,12 +179,13 @@
     ^ gotSema
 
     "Modified: 15.12.1995 / 23:10:54 / stefan"
+    "Modified: 16.12.1995 / 02:22:53 / cg"
 ! !
 
 !SemaphoreSet class methodsFor:'documentation'!
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/Attic/SemaSet.st,v 1.2 1995-12-16 01:16:24 stefan Exp $
+$Header: /cvs/stx/stx/libbasic/Attic/SemaSet.st,v 1.3 1995-12-16 01:23:30 cg Exp $
 "
 ! !
--- a/Semaphore.st	Sat Dec 16 02:16:25 1995 +0100
+++ b/Semaphore.st	Sat Dec 16 02:23:39 1995 +0100
@@ -10,8 +10,6 @@
  hereby transferred.
 "
 
-'From Smalltalk/X, Version:2.10.8 on 14-dec-1995 at 18:58:50'                   !
-
 Object subclass:#Semaphore
 	instanceVariableNames:'count waitingProcesses'
 	classVariableNames:''
@@ -320,7 +318,7 @@
 
 waitWithTimeout:seconds
     "wait for the semaphore, but abort the wait after some time.
-     return true if semaphore triggered normal, false if we return
+     return the receiver if semaphore triggered normal, nil if we return
      due to a timeout. With zero timeout, this can be used to poll
      a semaphore (which is not the intend of semaphores, though)."
 
@@ -333,15 +331,15 @@
      go mad ... (especially be careful when adding a debugPrint-here)
     "
     count ~~ 0 ifTrue:[
-	count := count - 1.
-	^ true
+        count := count - 1.
+        ^ self
     ].
 
     "
      with zero-timeout, this is a poll
     "
     seconds = 0 ifTrue:[
-	^ false
+        ^ nil
     ].
 
     current := Processor activeProcess.
@@ -364,31 +362,32 @@
      suspend.
     "
     [count == 0] whileTrue:[
-	waitingProcesses add:current.
+        waitingProcesses add:current.
 
-	timeoutOccured := false.
-	"
-	 for some more descriptive info in processMonitor ...
-	 ... set the state to #wait (instead of #suspend)
-	"
-	current suspendWithState:#wait.
+        timeoutOccured := false.
+        "
+         for some more descriptive info in processMonitor ...
+         ... set the state to #wait (instead of #suspend)
+        "
+        current suspendWithState:#wait.
 
-	timeoutOccured ifTrue:[
-	    waitingProcesses remove:current ifAbsent:[].
-	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-	    ^ false
-	].
+        timeoutOccured ifTrue:[
+            waitingProcesses remove:current ifAbsent:[].
+            wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+            ^ nil
+        ].
     ].
     Processor removeTimedBlock:unblock.
     count := count - 1.
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-    ^ true
+    ^ self
 
     "Modified: 13.12.1995 / 13:27:24 / stefan"
+    "Modified: 16.12.1995 / 02:21:19 / cg"
 ! !
 
 !Semaphore class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Semaphore.st,v 1.27 1995-12-16 01:16:25 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Semaphore.st,v 1.28 1995-12-16 01:23:39 cg Exp $'
 ! !
--- a/SemaphoreSet.st	Sat Dec 16 02:16:25 1995 +0100
+++ b/SemaphoreSet.st	Sat Dec 16 02:23:39 1995 +0100
@@ -1,5 +1,3 @@
-'From Smalltalk/X, Version:2.10.8 on 15-dec-1995 at 23:16:48'                   !
-
 IdentitySet subclass:#SemaphoreSet
 	instanceVariableNames:''
 	classVariableNames:''
@@ -128,6 +126,9 @@
 !
 
 waitWithTimeout:seconds
+    "wait for any of the the semaphore, but abort the wait after some time.
+     Return the first triggered semaphore if any, nil if we return due to a timeout."
+
     |currentProcess gotSema wasBlocked now endTime unblock timeoutOccured registeredAllSemas|
 
     currentProcess := Processor activeProcess.
@@ -178,12 +179,13 @@
     ^ gotSema
 
     "Modified: 15.12.1995 / 23:10:54 / stefan"
+    "Modified: 16.12.1995 / 02:22:53 / cg"
 ! !
 
 !SemaphoreSet class methodsFor:'documentation'!
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/SemaphoreSet.st,v 1.2 1995-12-16 01:16:24 stefan Exp $
+$Header: /cvs/stx/stx/libbasic/SemaphoreSet.st,v 1.3 1995-12-16 01:23:30 cg Exp $
 "
 ! !