Do not use this_thread::sleep or thread::hardware_concurrency.

Mingw doesn't implement them. So, we should not use it.
I suppose that it was working before because mingw package for debian trusty
simply no provides a "thread" header.
We may face to include the native "thread" header.
This commit is contained in:
Matthieu Gautier 2019-04-17 15:48:33 +00:00
parent 77dc2ef2ed
commit 2774eb9529
2 changed files with 4 additions and 5 deletions

View File

@ -28,8 +28,7 @@
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <thread> #include <time.h>
#include <chrono>
using namespace std; using namespace std;
@ -240,7 +239,8 @@ bool handle_download(kiwix::Library* library, const std::string& libraryPath,
exitCode = true; exitCode = true;
break; break;
} }
std::this_thread::sleep_for(std::chrono::seconds(1)); struct timespec wait = {1, 0};
nanosleep(&wait, nullptr);
} }
downloader.close(); downloader.close();

View File

@ -67,7 +67,6 @@ extern "C" {
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <sstream> #include <sstream>
#include <thread>
#include <string> #include <string>
#include <vector> #include <vector>
#include "server-resources.h" #include "server-resources.h"
@ -949,7 +948,7 @@ int main(int argc, char** argv)
int libraryFlag = false; int libraryFlag = false;
string PPIDString; string PPIDString;
unsigned int PPID = 0; unsigned int PPID = 0;
unsigned int nb_threads = std::thread::hardware_concurrency(); unsigned int nb_threads = 4;
static struct option long_options[] static struct option long_options[]
= {{"daemon", no_argument, 0, 'd'}, = {{"daemon", no_argument, 0, 'd'},