changeset 2242:4e8e0ad2001c

move USleep() in SystemToolbox
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Dec 2016 15:31:01 +0100
parents eb363ec95d86
children 2dbfdafc2512
files Core/SystemToolbox.cpp Core/SystemToolbox.h Core/Toolbox.cpp Core/Toolbox.h Core/WebServiceParameters.cpp Resources/CMake/BoostConfiguration.cmake UnitTestsSources/MultiThreadingTests.cpp
diffstat 7 files changed, 32 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/Core/SystemToolbox.cpp	Fri Dec 16 19:59:48 2016 +0100
+++ b/Core/SystemToolbox.cpp	Mon Dec 19 15:31:01 2016 +0100
@@ -123,7 +123,7 @@
     barrierEvent_ = ServerBarrierEvent_Stop;
     while (!(*stopFlag || finish_))
     {
-      Toolbox::USleep(100 * 1000);
+      SystemToolbox::USleep(100 * 1000);
     }
 
 #if defined(_WIN32)
@@ -152,6 +152,18 @@
   }
 
 
+  void SystemToolbox::USleep(uint64_t microSeconds)
+  {
+#if defined(_WIN32)
+    ::Sleep(static_cast<DWORD>(microSeconds / static_cast<uint64_t>(1000)));
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__native_client__)
+    usleep(microSeconds);
+#else
+#error Support your platform here
+#endif
+  }
+
+
   static std::streamsize GetStreamSize(std::istream& f)
   {
     // http://www.cplusplus.com/reference/iostream/istream/tellg/
--- a/Core/SystemToolbox.h	Fri Dec 16 19:59:48 2016 +0100
+++ b/Core/SystemToolbox.h	Mon Dec 19 15:31:01 2016 +0100
@@ -50,6 +50,8 @@
 {
   namespace SystemToolbox
   {
+    void USleep(uint64_t microSeconds);
+
     ServerBarrierEvent ServerBarrier(const bool& stopFlag);
 
     ServerBarrierEvent ServerBarrier();
--- a/Core/Toolbox.cpp	Fri Dec 16 19:59:48 2016 +0100
+++ b/Core/Toolbox.cpp	Mon Dec 19 15:31:01 2016 +0100
@@ -90,18 +90,6 @@
 
 namespace Orthanc
 {
-  void Toolbox::USleep(uint64_t microSeconds)
-  {
-#if defined(_WIN32)
-    ::Sleep(static_cast<DWORD>(microSeconds / static_cast<uint64_t>(1000)));
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__native_client__)
-    usleep(microSeconds);
-#else
-#error Support your platform here
-#endif
-  }
-
-
   void Toolbox::ToUpperCase(std::string& s)
   {
     std::transform(s.begin(), s.end(), s.begin(), toupper);
--- a/Core/Toolbox.h	Fri Dec 16 19:59:48 2016 +0100
+++ b/Core/Toolbox.h	Mon Dec 19 15:31:01 2016 +0100
@@ -78,8 +78,6 @@
 
   namespace Toolbox
   {
-    void USleep(uint64_t microSeconds);
-
     void ToUpperCase(std::string& s);  // Inplace version
 
     void ToLowerCase(std::string& s);  // Inplace version
--- a/Core/WebServiceParameters.cpp	Fri Dec 16 19:59:48 2016 +0100
+++ b/Core/WebServiceParameters.cpp	Mon Dec 19 15:31:01 2016 +0100
@@ -34,7 +34,6 @@
 #include "WebServiceParameters.h"
 
 #include "../Core/Logging.h"
-#include "../Core/Toolbox.h"
 #include "../Core/OrthancException.h"
 
 #if ORTHANC_SANDBOXED == 0
--- a/Resources/CMake/BoostConfiguration.cmake	Fri Dec 16 19:59:48 2016 +0100
+++ b/Resources/CMake/BoostConfiguration.cmake	Mon Dec 19 15:31:01 2016 +0100
@@ -99,6 +99,13 @@
       -DBOOST_LOCALE_NO_POSIX_BACKEND=1
       -DBOOST_LOCALE_NO_STD_BACKEND=1
       )
+
+  elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
+    add_definitions(
+      -DBOOST_LOCALE_NO_POSIX_BACKEND=1
+      -DBOOST_LOCALE_NO_STD_BACKEND=1
+      )
+
   else()
     message(FATAL_ERROR "Support your platform here")
   endif()
@@ -114,10 +121,15 @@
   list(APPEND BOOST_SOURCES
     ${BOOST_REGEX_SOURCES}
     ${BOOST_SOURCES_DIR}/libs/date_time/src/gregorian/greg_month.cpp
-    ${BOOST_SOURCES_DIR}/libs/locale/src/encoding/codepage.cpp
     ${BOOST_SOURCES_DIR}/libs/system/src/error_code.cpp
     )
 
+  if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
+    list(APPEND BOOST_SOURCES
+      ${BOOST_SOURCES_DIR}/libs/locale/src/encoding/codepage.cpp
+      )
+  endif()
+
   if (${CMAKE_SYSTEM_NAME} STREQUAL "PNaCl" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "NaCl32" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "NaCl64")
--- a/UnitTestsSources/MultiThreadingTests.cpp	Fri Dec 16 19:59:48 2016 +0100
+++ b/UnitTestsSources/MultiThreadingTests.cpp	Mon Dec 19 15:31:01 2016 +0100
@@ -143,7 +143,7 @@
   }
 
   printf("**\n"); fflush(stdout);
-  Toolbox::USleep(1000000);
+  SystemToolbox::USleep(1000000);
   printf("**\n"); fflush(stdout);
 
   {
@@ -184,7 +184,7 @@
       outputs.push_back(boost::lexical_cast<std::string>(b));
     }
 
-    Toolbox::USleep(30000);
+    SystemToolbox::USleep(30000);
 
     return true;
   }
@@ -203,7 +203,7 @@
     {
       printf(">> %s: %0.1f\n", it->c_str(), 100.0f * s->GetProgress(*it));
     }
-    Toolbox::USleep(3000);
+    SystemToolbox::USleep(3000);
   }
 }
 
@@ -248,7 +248,7 @@
   }
 
   //SystemToolbox::ServerBarrier();
-  //Toolbox::USleep(3000000);
+  //SystemToolbox::USleep(3000000);
 
   scheduler.Stop();