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