Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Aug 10, 2023
1 parent 4fed00d commit 37a7a4b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/util/precise_sleep.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#include "precise_sleep.hpp"

namespace NUClear {
namespace util {

#if defined(_WIN32)

#include <chrono>
#include <cstdint>

#include "platform.hpp"

// Keep this include here
#ifdef _WIN32
#include <synchapi.h>
#endif
namespace NUClear {
namespace util {

void precise_sleep(const std::chrono::nanoseconds& ns) {
::LARGE_INTEGER ft;
Expand All @@ -28,12 +23,18 @@ namespace util {
::CloseHandle(timer);
}

} // namespace util
} // namespace NUClear

#else

#include <cerrno>
#include <cstdint>
#include <ctime>

namespace NUClear {
namespace util {

void precise_sleep(const std::chrono::nanoseconds& ns) {
struct timespec ts;
ts.tv_sec = std::chrono::duration_cast<std::chrono::seconds>(ns).count();
Expand All @@ -43,7 +44,7 @@ namespace util {
}
}

#endif

} // namespace util
} // namespace NUClear

#endif

0 comments on commit 37a7a4b

Please sign in to comment.