DatabaseThread optimized

This commit is contained in:
Rafael 2016-04-13 16:03:08 +02:00
parent 82d7967c04
commit 0089a6d7f6
2 changed files with 15 additions and 11 deletions

View File

@ -33,6 +33,7 @@
DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB) DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB)
{ {
crewMaxPages = 83; crewMaxPages = 83;
threadRunning = true;
} }
void DatabaseThread::run() void DatabaseThread::run()
@ -52,20 +53,22 @@ void DatabaseThread::run()
emit playerNameUpdated(); emit playerNameUpdated();
} }
QEventLoop waitingLoop; QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(10000, &waitingLoop, SLOT(quit())); QTimer::singleShot(10000, waitingLoop, SLOT(quit()));
waitingLoop.exec(); waitingLoop->exec();
delete waitingLoop;
dbtBegin: while (threadRunning)
crewList = crewDB->getCrews(); {
crewList = crewDB->getCrews();
// Long time scan // Long time scan
scanCrewMembersList(crewList, crewMaxPages, 10000); scanCrewMembersList(crewList, crewMaxPages, 10000);
emit playerNameUpdated(); emit playerNameUpdated();
QTimer::singleShot(300000, &threadLoop, SLOT(quit())); QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec(); threadLoop.exec();
goto dbtBegin; }
} }
void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay) void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay)

View File

@ -32,6 +32,7 @@ public:
private: private:
CrewDatabase *crewDB; CrewDatabase *crewDB;
void scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay); void scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay);
bool threadRunning;
int crewMaxPages; int crewMaxPages;
int plyrPerReq; int plyrPerReq;