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.

54 lines
1.4 KiB

  1. --- a/src/data/hash_queue.cc
  2. +++ b/src/data/hash_queue.cc
  3. @@ -38,9 +38,10 @@
  4. #define __STDC_FORMAT_MACROS
  5. +#include <chrono>
  6. +#include <thread>
  7. #include <functional>
  8. #include <rak/functional.h>
  9. -#include <unistd.h>
  10. #include "torrent/exceptions.h"
  11. #include "torrent/data/download_data.h"
  12. @@ -137,7 +138,7 @@ HashQueue::remove(HashQueueNode::id_type id) {
  13. while ((done_itr = m_done_chunks.find(hash_chunk)) == m_done_chunks.end()) {
  14. pthread_mutex_unlock(&m_done_chunks_lock);
  15. - usleep(100);
  16. + std::this_thread::sleep_for(std::chrono::microseconds(100));
  17. pthread_mutex_lock(&m_done_chunks_lock);
  18. }
  19. --- a/src/torrent/utils/thread_base.cc
  20. +++ b/src/torrent/utils/thread_base.cc
  21. @@ -37,8 +37,9 @@
  22. #include "config.h"
  23. #include <cstring>
  24. +#include <chrono>
  25. +#include <thread>
  26. #include <signal.h>
  27. -#include <unistd.h>
  28. #include "exceptions.h"
  29. #include "poll.h"
  30. @@ -97,7 +98,7 @@ thread_base::stop_thread_wait() {
  31. release_global_lock();
  32. while (!is_inactive()) {
  33. - usleep(1000);
  34. + std::this_thread::sleep_for(std::chrono::milliseconds(1));
  35. }
  36. acquire_global_lock();
  37. @@ -161,7 +162,7 @@ thread_base::event_loop(thread_base* thread) {
  38. }
  39. // Add the sleep call when testing interrupts, etc.
  40. - // usleep(50);
  41. + // std::this_thread::sleep_for(std::chrono::microseconds(50));
  42. int poll_flags = 0;