You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.2 KiB

  1. From d35215b50bfea42c8a1d884c65fda1dee8b62d50 Mon Sep 17 00:00:00 2001
  2. From: Michael Behrisch <michael.behrisch@dlr.de>
  3. Date: Fri, 4 Oct 2019 11:41:29 +0200
  4. Subject: [PATCH] removing usleep, refs #12, fix #6133
  5. ---
  6. src/utils/foxtools/FXSingleEventThread.cpp | 9 +++------
  7. src/utils/iodevices/OutputDevice_Network.cpp | 17 ++++-------------
  8. 2 files changed, 7 insertions(+), 19 deletions(-)
  9. diff --git a/src/utils/foxtools/FXSingleEventThread.cpp b/src/utils/foxtools/FXSingleEventThread.cpp
  10. index 4b12fb920f..f545c18439 100644
  11. --- a/src/utils/foxtools/FXSingleEventThread.cpp
  12. +++ b/src/utils/foxtools/FXSingleEventThread.cpp
  13. @@ -35,6 +35,8 @@
  14. #else
  15. #include <process.h>
  16. #endif
  17. +#include <chrono>
  18. +#include <thread>
  19. #ifndef WIN32
  20. # define PIPE_READ 0
  21. @@ -137,12 +139,7 @@ FXSingleEventThread::onThreadEvent(FXObject*, FXSelector, void*) {
  22. void
  23. FXSingleEventThread::sleep(long ms) {
  24. -#ifdef WIN32
  25. - Sleep(ms);
  26. -#else
  27. - long long us = ms * 1000;
  28. - usleep(us);
  29. -#endif
  30. + std::this_thread::sleep_for(std::chrono::milliseconds(ms));
  31. }
  32. diff --git a/src/utils/iodevices/OutputDevice_Network.cpp b/src/utils/iodevices/OutputDevice_Network.cpp
  33. index 2c20ce96aa..6bde32e1e6 100644
  34. --- a/src/utils/iodevices/OutputDevice_Network.cpp
  35. +++ b/src/utils/iodevices/OutputDevice_Network.cpp
  36. @@ -21,15 +21,10 @@
  37. // ==========================================================================
  38. // included modules
  39. // ==========================================================================
  40. -#include <config.h> // #ifdef _MSC_VER
  41. +#include <config.h>
  42. -#ifdef WIN32
  43. -#define NOMINMAX
  44. -#include <windows.h>
  45. -#undef NOMINMAX
  46. -#else
  47. -#include <unistd.h>
  48. -#endif
  49. +#include <thread>
  50. +#include <chrono>
  51. #include <vector>
  52. #include "OutputDevice_Network.h"
  53. #include "foreign/tcpip/socket.h"
  54. @@ -57,11 +52,7 @@ OutputDevice_Network::OutputDevice_Network(const std::string& host,
  55. if (wait == 9000) {
  56. throw IOError(toString(e.what()) + " (host: " + host + ", port: " + toString(port) + ")");
  57. }
  58. -#ifdef WIN32
  59. - Sleep(wait);
  60. -#else
  61. - usleep(wait * 1000);
  62. -#endif
  63. + std::this_thread::sleep_for(std::chrono::milliseconds(wait));
  64. }
  65. }
  66. myFilename = host + ":" + toString(port);