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.

36 lines
897 B

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. // An OS-independent sleep function.
  11. #include "system_wrappers/include/sleep.h"
  12. #ifdef _WIN32
  13. // For Sleep()
  14. #include <windows.h>
  15. #else
  16. // For nanosleep()
  17. #include <time.h>
  18. #endif
  19. namespace webrtc {
  20. void SleepMs(int msecs) {
  21. #ifdef _WIN32
  22. Sleep(msecs);
  23. #else
  24. struct timespec short_wait;
  25. struct timespec remainder;
  26. short_wait.tv_sec = msecs / 1000;
  27. short_wait.tv_nsec = (msecs % 1000) * 1000 * 1000;
  28. nanosleep(&short_wait, &remainder);
  29. #endif
  30. }
  31. } // namespace webrtc