void Project::onJobFinished(const shared_ptr<IndexerJob> &job) { PendingJob pending; bool startPending = false; { MutexLocker lock(&mMutex); const uint32_t fileId = job->fileId(); if (job->isAborted()) { mVisitedFiles -= job->visitedFiles(); --mJobCounter; pending = mPendingJobs.take(fileId, &startPending); if (mJobs.value(fileId) == job) mJobs.remove(fileId); } else { assert(mJobs.value(fileId) == job); mJobs.remove(fileId); shared_ptr<IndexData> data = job->data(); mPendingData[fileId] = data; const int idx = mJobCounter - mJobs.size(); mSources[fileId].parsed = job->parseTime(); error("[%3d%%] %d/%d %s %s.", static_cast<int>(round((double(idx) / double(mJobCounter)) * 100.0)), idx, mJobCounter, String::formatTime(time(0), String::Time).constData(), data->message.constData()); if (mJobs.isEmpty() && job->flags() & IndexerJob::Dirty) { const int syncTime = syncDB(); error() << "Jobs took" << (static_cast<double>(mTimer.elapsed()) / 1000.0) << "secs, syncing took" << (static_cast<double>(syncTime) / 1000.0) << " secs, using" << MemoryMonitor::usage() / (1024.0 * 1024.0) << "mb of memory"; mTimerRunning = false; mSaveTimer.start(shared_from_this(), SaveTimeout, SingleShot, Save); mJobCounter = 0; } else if (mJobs.isEmpty()) { mSyncTimer.start(shared_from_this(), SyncTimeout, SingleShot, Sync); } } } if (startPending) index(pending.source, pending.type); }
void Project::timerEvent(TimerEvent *e) { if (e->userData() == Save) { save(); } else if (e->userData() == Sync) { const int syncTime = syncDB(); error() << "Jobs took" << (static_cast<double>(mTimer.elapsed()) / 1000.0) << "secs, syncing took" << (static_cast<double>(syncTime) / 1000.0) << " secs, using" << MemoryMonitor::usage() / (1024.0 * 1024.0) << "mb of memory"; mSaveTimer.start(shared_from_this(), SaveTimeout, SingleShot, Save); mJobCounter = 0; } else if (e->userData() == ModifiedFiles) { startDirtyJobs(); } else { assert(0 && "Unexpected timer event in Project"); e->stop(); } }