#FEATURE by stefan
class: SemaphoreSet
changed: #waitWithTimeout:
allow TimeDuration as argument (protocol compatibility with Semaphore)
--- a/SemaphoreSet.st Tue Feb 21 15:42:43 2017 +0100
+++ b/SemaphoreSet.st Tue Feb 21 15:47:04 2017 +0100
@@ -218,19 +218,25 @@
"Modified: 20.8.1997 / 18:33:09 / cg"
!
-waitWithTimeout:seconds
+waitWithTimeout:secondsOrNilOrTimeDuration
"wait for any of the semaphore, but abort the wait after some time (seconds).
Return the (first) triggered semaphore if any, nil if we return due to a timeout."
|millis|
- seconds notNil ifTrue:[
- millis := seconds * 1000
+ secondsOrNilOrTimeDuration notNil ifTrue:[
+ secondsOrNilOrTimeDuration isNumber ifTrue:[
+ millis := secondsOrNilOrTimeDuration.
+ ] ifFalse:[
+ "converts a TimeDuration to a Fraction"
+ millis := secondsOrNilOrTimeDuration asFraction.
+ ].
+ millis := (millis * 1000) asInteger
].
^ self waitWithTimeoutMs:millis.
- "Modified: 15.12.1995 / 23:10:54 / stefan"
- "Modified: 20.8.1997 / 18:33:23 / cg"
+ "Modified: / 20-08-1997 / 18:33:23 / cg"
+ "Modified: / 21-02-2017 / 14:48:48 / stefan"
!
waitWithTimeoutMs:milliSeconds