Win32OperatingSystem.st
changeset 18414 7a9f549dc84e
parent 17632 0f6674a899a0
child 18418 a1b089286b67
child 18543 fef08f652ef8
--- a/Win32OperatingSystem.st	Wed May 27 21:09:55 2015 +0200
+++ b/Win32OperatingSystem.st	Thu May 28 14:22:10 2015 +0200
@@ -7029,6 +7029,43 @@
     self terminateProcess:processId
 !
 
+microsecondSleep:micros
+    "cease ANY action for some time. 
+     This suspends the whole smalltalk (unix/windows-) process for some time.
+     Not really useful since not even low-prio processes and interrupt
+     handling will run during the sleep.
+     Use either OperatingSystem>>millisecondDelay: (which makes all
+     threads sleep, but handles interrupts) or use a Delay 
+     (which makes only the calling thread sleep)."
+
+    |uLow uHigh|
+
+    uLow := micros // 1000000.
+    uHigh := micros \\ 1000000.
+%{
+    struct timeval tv;
+    fd_set dummy;
+    int success;
+
+    SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+    FD_ZERO(&dummy);
+    FD_SET(s, &dummy);
+    tv.tv_sec = __intVal(uLow);
+    tv.tv_usec = __intVal(uHigh);
+    success = (0 == select(0, 0, 0, &dummy, &tv));
+    closesocket(s);
+    RETURN (success ? true : false);
+%}
+
+    "
+     Timestamp now printCR.
+     OperatingSystem microsecondSleep:100.
+     Timestamp now printCR.
+    "
+
+    "Created: / 28-05-2015 / 14:14:53 / gg"
+!
+
 sendSignal:signalNumber to:processId
     "send a unix signal to some process (maybe myself).
      Returns false if any error occurred, true otherwise.
@@ -18323,15 +18360,15 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.526 2015-03-20 11:28:32 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.527 2015-05-28 12:22:10 sr Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.526 2015-03-20 11:28:32 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.527 2015-05-28 12:22:10 sr Exp $'
 !
 
 version_SVN
-    ^ '$Id: Win32OperatingSystem.st,v 1.526 2015-03-20 11:28:32 stefan Exp $'
+    ^ '$Id: Win32OperatingSystem.st,v 1.527 2015-05-28 12:22:10 sr Exp $'
 
 ! !