diff --git a/libraries/networking/src/udt/SendQueue.cpp b/libraries/networking/src/udt/SendQueue.cpp index 3149c5c7bf..8e5141b58a 100644 --- a/libraries/networking/src/udt/SendQueue.cpp +++ b/libraries/networking/src/udt/SendQueue.cpp @@ -29,6 +29,7 @@ #include "Socket.h" using namespace udt; +using namespace std::chrono; template class DoubleLock { @@ -303,15 +304,12 @@ void SendQueue::run() { if (_state != State::Running || isInactive(sentAPacket)) { return; } - - // grab the current HRC timestamp - const auto now = p_high_resolution_clock::now(); // push the next packet timestamp forwards by the current packet send period nextPacketTimestamp += std::chrono::microseconds(_packetSendPeriod); // sleep as long as we need until next packet send, if we can - const auto timeToSleep = std::chrono::duration_cast(nextPacketTimestamp - now); + const auto timeToSleep = duration_cast(nextPacketTimestamp - p_high_resolution_clock::now()); std::this_thread::sleep_for(timeToSleep); }