+ introduce Sleep() for Windows

This commit is contained in:
kelson42 2012-04-19 12:10:05 +00:00
parent 9c3c3a1f68
commit b40a317bf0
2 changed files with 29 additions and 1 deletions

View File

@ -189,7 +189,11 @@ namespace kiwix {
/* Wait that the extraction has started, and so on a few
initialisations, to really start */
while(self->isToIndexQueueEmpty() && self->isArticleExtractorRunning()) {
#ifdef _WIN32
Sleep(100);
#else
sleep(0.1);
#endif
}
indexerToken token;
@ -228,7 +232,11 @@ namespace kiwix {
}
self->setProgression(100);
self->indexingPostlude();
#ifdef _WIN32
Sleep(100);
#else
sleep(1);
#endif
self->articleIndexerRunning(false);
pthread_exit(NULL);
return NULL;
@ -259,12 +267,20 @@ namespace kiwix {
pthread_mutex_lock(&toParseQueueMutex);
this->toParseQueue.push(token);
pthread_mutex_unlock(&toParseQueueMutex);
#ifdef _WIN32
Sleep(int(this->toParseQueue.size() / 200) / 10 * 1000);
#else
sleep(int(this->toParseQueue.size() / 200) / 10);
#endif
}
bool Indexer::popFromToParseQueue(indexerToken &token) {
while (this->isToParseQueueEmpty() && this->isArticleExtractorRunning()) {
#ifdef _WIN32
Sleep(500);
#else
sleep(0.5);
#endif
pthread_testcancel();
}
@ -292,12 +308,20 @@ namespace kiwix {
pthread_mutex_lock(&toIndexQueueMutex);
this->toIndexQueue.push(token);
pthread_mutex_unlock(&toIndexQueueMutex);
#ifdef _WIN32
Sleep(int(this->toIndexQueue.size() / 200) / 10 * 1000);
#else
sleep(int(this->toIndexQueue.size() / 200) / 10);
#endif
}
bool Indexer::popFromToIndexQueue(indexerToken &token) {
while (this->isToIndexQueueEmpty() && this->isArticleParserRunning()) {
#ifdef _WIN32
Sleep(500);
#else
sleep(0.5);
#endif
pthread_testcancel();
}

View File

@ -28,6 +28,10 @@
#include <iostream>
#include <sstream>
#ifdef _WIN32
#include <Windows.h>
#endif
#include <pthread.h>
#include <unaccent.h>
#include <zim/file.h>