]> OCCT Git - occt.git/commitdiff
0031768: Foundation Classes - use usleep within OSD::MilliSecSleep()
authorkgv <kgv@opencascade.com>
Tue, 15 Sep 2020 10:05:06 +0000 (13:05 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 18 Sep 2020 14:46:52 +0000 (17:46 +0300)
src/OSD/OSD.cxx
src/OSD/OSD.hxx

index b8c975744cb40354bf32a9c7744ae40b8c0a2126..3a235a1d478d6125db3b4c7006510314181c88cf 100644 (file)
@@ -55,48 +55,34 @@ Standard_Boolean OSD::CStringToReal(const Standard_CString aString,
   return Standard_True;
 }
 
+#ifdef _WIN32
+  #include <windows.h>
+#else
+  #include <unistd.h>
+#endif
+
 //=======================================================================
 //function : OSDSecSleep
 //purpose  : Cause the process to sleep during a amount of seconds 
 //=======================================================================
-
+void OSD::SecSleep (const Standard_Integer theSeconds)
+{
 #ifdef _WIN32
-# include <windows.h>
-# define SLEEP(NSEC)                 Sleep(1000*(NSEC))
+  Sleep (theSeconds * 1000);
 #else
-#include <unistd.h>
-# define SLEEP(NSEC)                 sleep(NSEC)
+  usleep (theSeconds * 1000 * 1000);
 #endif
-
-void OSD::SecSleep(const Standard_Integer aDelay)
-{
-  SLEEP(aDelay);
 }
 
 //=======================================================================
 //function : MilliSecSleep
 //purpose  : Cause the process to sleep during a amount of milliseconds  
 //=======================================================================
-
-#ifdef _WIN32
-
-void OSD::MilliSecSleep(const Standard_Integer aDelay)
+void OSD::MilliSecSleep (const Standard_Integer theMilliseconds)
 {
-  Sleep(aDelay) ;
-}
-
+#ifdef _WIN32
+  Sleep (theMilliseconds);
 #else
-
-#include <sys/time.h>
-
-void OSD::MilliSecSleep(const Standard_Integer aDelay)
-{
-  struct timeval timeout ;
-
-  timeout.tv_sec = aDelay / 1000 ;
-  timeout.tv_usec = (aDelay % 1000) * 1000 ;
-
-  select(0,NULL,NULL,NULL,&timeout) ;
-}
-
+  usleep (theMilliseconds * 1000);
 #endif
+}
index 03dc1eea87515cb53c103883eea5625e0ad6fa46..78cfb38d5abbe99e359c3f692363e6ff6cee5fbb 100644 (file)
@@ -113,11 +113,11 @@ public:
   Standard_EXPORT static Standard_Boolean ToCatchFloatingSignals();
 
   //! Commands the process to sleep for a number of seconds.
-  Standard_EXPORT static void SecSleep (const Standard_Integer aDelay);
-  
+  Standard_EXPORT static void SecSleep (const Standard_Integer theSeconds);
+
   //! Commands the process to sleep for a number of milliseconds
-  Standard_EXPORT static void MilliSecSleep (const Standard_Integer aDelay);
-  
+  Standard_EXPORT static void MilliSecSleep (const Standard_Integer theMilliseconds);
+
   //! Converts aReal into aCstring in exponential format with a period as
   //! decimal point, no thousand separator and no grouping of digits.
   //! The conversion is independant from the current locale