Delay.st
branchjv
changeset 18120 e3a375d5f6a8
parent 18084 ab5b38bd8f81
parent 16404 ebb89de51a93
child 18997 da0370e39ece
--- a/Delay.st	Tue Feb 04 21:09:59 2014 +0100
+++ b/Delay.st	Wed Apr 01 10:20:10 2015 +0100
@@ -148,6 +148,16 @@
 
 !Delay class methodsFor:'instance creation'!
 
+for:aTimeDuration
+    "return a new Delay object for delaying aNumber seconds"
+
+    ^ self new delay:aTimeDuration getMilliseconds.
+
+    "
+      Delay for:10 seconds
+    "
+!
+
 forMilliseconds:aNumber
     "return a new Delay object for delaying aNumber milliseconds"
 
@@ -166,7 +176,8 @@
 
     |numberOfMilliseconds|
 
-    numberOfMilliseconds := aTimeStamp getMilliseconds - Timestamp now getMilliseconds.
+    "/ numberOfMilliseconds := aTimeStamp getMilliseconds - Timestamp now getMilliseconds.
+    numberOfMilliseconds := aTimeStamp millisecondDeltaFrom:Timestamp now.
     ^ self new delay:numberOfMilliseconds
 !
 
@@ -309,17 +320,16 @@
             Processor signal:delaySemaphore atMilliseconds:then.
             Processor activeProcess setStateTo:#timeWait if:#active.
             delaySemaphore wait.
-        ] doWhile:[
-            (dueTime notNil
+
+            dueTime notNil
               and:[isInterrupted not
-              and:[(currentDelta := dueTime - OperatingSystem getMicrosecondTime) > 0]]
-            ) ifTrue:[
+              and:[(currentDelta := dueTime - OperatingSystem getMicrosecondTime) > 0
+              and:[
                 currentDelta := (currentDelta // 1000) min:16r0fffffff.
                 now := OperatingSystem getMillisecondTime.
                 then := OperatingSystem millisecondTimeAdd:now and:currentDelta.
-                true.
-            ] ifFalse:[ false ]
-        ].
+                true.]]]
+        ] whileTrue.
     ] ensure:[
         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
     ]
@@ -359,10 +369,10 @@
 !Delay class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Delay.st,v 1.48 2013-08-16 09:38:32 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Delay.st,v 1.51 2014-05-07 14:30:39 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Delay.st,v 1.48 2013-08-16 09:38:32 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Delay.st,v 1.51 2014-05-07 14:30:39 stefan Exp $'
 ! !