|
@@ -21,16 +21,12 @@
|
21
|
21
|
*/
|
22
|
22
|
|
23
|
23
|
#include "time.h"
|
24
|
|
-#include <boost/chrono.hpp>
|
25
|
|
-#ifdef _MSC_VER
|
|
24
|
+#include <chrono>
|
26
|
25
|
#include <thread>
|
27
|
|
-#else
|
28
|
|
-#include <unistd.h>
|
29
|
|
-#endif
|
30
|
26
|
|
31
|
27
|
namespace stdext {
|
32
|
28
|
|
33
|
|
-const static auto startup_time = boost::chrono::high_resolution_clock::now();
|
|
29
|
+const static auto startup_time = std::chrono::high_resolution_clock::now();
|
34
|
30
|
|
35
|
31
|
ticks_t time() {
|
36
|
32
|
return std::time(NULL);
|
|
@@ -38,28 +34,20 @@ ticks_t time() {
|
38
|
34
|
|
39
|
35
|
ticks_t millis()
|
40
|
36
|
{
|
41
|
|
- return boost::chrono::duration_cast<boost::chrono::milliseconds>(boost::chrono::high_resolution_clock::now() - startup_time).count();
|
|
37
|
+ return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
|
42
|
38
|
}
|
43
|
39
|
ticks_t micros() {
|
44
|
|
- return boost::chrono::duration_cast<boost::chrono::microseconds>(boost::chrono::high_resolution_clock::now() - startup_time).count();
|
|
40
|
+ return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
|
45
|
41
|
}
|
46
|
42
|
|
47
|
43
|
void millisleep(size_t ms)
|
48
|
44
|
{
|
49
|
|
-#ifdef _MSC_VER
|
50
|
45
|
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
51
|
|
-#else
|
52
|
|
- usleep(ms * 1000);
|
53
|
|
-#endif
|
54
|
46
|
};
|
55
|
47
|
|
56
|
48
|
void microsleep(size_t us)
|
57
|
49
|
{
|
58
|
|
-#ifdef _MSC_VER
|
59
|
50
|
std::this_thread::sleep_for(std::chrono::microseconds(us));
|
60
|
|
-#else
|
61
|
|
- usleep(us);
|
62
|
|
-#endif
|
63
|
51
|
};
|
64
|
52
|
|
65
|
53
|
}
|