Changeset 11098 for code/trunk/src/libraries/util/Sleep.cc
- Timestamp:
- Jan 26, 2016, 8:32:16 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/util/Sleep.cc
r8858 r11098 30 30 @file 31 31 @brief 32 Implementation of three sleep functions. Avoids including windows.h32 Implementation of three sleep functions. 33 33 */ 34 34 35 35 #include "Sleep.h" 36 #include "Output.h"37 36 38 #ifdef ORXONOX_PLATFORM_WINDOWS 39 #ifndef WIN32_LEAN_AND_MEAN 40 # define WIN32_LEAN_AND_MEAN 41 #endif 42 #include <windows.h> 43 #undef min 44 #undef max 37 #include <chrono> 38 #include <thread> 45 39 46 40 namespace orxonox … … 48 42 void usleep(unsigned long microseconds) 49 43 { 50 //if (microseconds < 1000) 51 // orxout(internal_warning) << "Windows cannot sleep less than 1ms, ignoring" << endl; 52 Sleep(microseconds / 1000); 44 std::this_thread::sleep_for(std::chrono::microseconds(microseconds)); 53 45 } 54 46 55 47 void msleep(unsigned long milliseconds) 56 48 { 57 Sleep(milliseconds);49 std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); 58 50 } 59 51 60 52 void sleep(unsigned long seconds) 61 53 { 62 Sleep(seconds * 1000);54 std::this_thread::sleep_for(std::chrono::seconds(seconds)); 63 55 } 64 56 } 65 66 #else /* Linux/Apple */67 #include <unistd.h>68 69 namespace orxonox70 {71 void usleep(unsigned long usec)72 {73 ::usleep(usec);74 }75 void msleep(unsigned long msec)76 {77 ::usleep(msec * 1000);78 }79 void sleep(unsigned long sec)80 {81 ::usleep(sec * 1000000);82 }83 }84 85 #endif
Note: See TracChangeset
for help on using the changeset viewer.