Fix build

This commit is contained in:
Jacob Dufault 2018-01-07 13:37:30 -08:00
parent 74c75ad0d1
commit ab41e0353c
2 changed files with 8 additions and 6 deletions

View File

@ -34,8 +34,6 @@ long long GetCurrentTimeInMilliseconds() {
// Send indexing progress to client if reporting is enabled. // Send indexing progress to client if reporting is enabled.
void EmitProgress(Config* config, ImportPipelineStatus* status) { void EmitProgress(Config* config, ImportPipelineStatus* status) {
static std::atomic<long long> next_output = 0;
if (config->progressReportFrequencyMs >= 0) { if (config->progressReportFrequencyMs >= 0) {
auto* queue = QueueManager::instance(); auto* queue = QueueManager::instance();
Out_Progress out; Out_Progress out;
@ -54,9 +52,10 @@ void EmitProgress(Config* config, ImportPipelineStatus* status) {
out.params.loadPreviousIndexCount != 0 || out.params.loadPreviousIndexCount != 0 ||
out.params.onIdMappedCount != 0 || out.params.onIndexedCount != 0 || out.params.onIdMappedCount != 0 || out.params.onIndexedCount != 0 ||
out.params.activeThreads != 0; out.params.activeThreads != 0;
if (!has_state || GetCurrentTimeInMilliseconds() < next_output) if (!has_state ||
GetCurrentTimeInMilliseconds() < status->next_progress_output)
return; return;
next_output = status->next_progress_output =
GetCurrentTimeInMilliseconds() + config->progressReportFrequencyMs; GetCurrentTimeInMilliseconds() + config->progressReportFrequencyMs;
} }
@ -402,7 +401,8 @@ bool IndexMergeIndexUpdates() {
} // namespace } // namespace
ImportPipelineStatus::ImportPipelineStatus() : num_active_threads(0) {} ImportPipelineStatus::ImportPipelineStatus()
: num_active_threads(0), next_progress_output(0) {}
// Index a file using an already-parsed translation unit from code completion. // Index a file using an already-parsed translation unit from code completion.
// Since most of the time for indexing a file comes from parsing, we can do // Since most of the time for indexing a file comes from parsing, we can do
@ -499,9 +499,9 @@ bool QueryDb_ImportMain(Config* config,
WorkingFiles* working_files) { WorkingFiles* working_files) {
std::unique_ptr<ICacheManager> cache_manager = ICacheManager::Make(config); std::unique_ptr<ICacheManager> cache_manager = ICacheManager::Make(config);
auto* queue = QueueManager::instance(); auto* queue = QueueManager::instance();
EmitProgress(config, status);
status->num_active_threads++; status->num_active_threads++;
EmitProgress(config, status);
bool did_work = false; bool did_work = false;
@ -615,6 +615,7 @@ bool QueryDb_ImportMain(Config* config,
} }
status->num_active_threads--; status->num_active_threads--;
EmitProgress(config, status);
return did_work; return did_work;
} }

View File

@ -20,6 +20,7 @@ struct WorkingFiles;
struct ImportPipelineStatus { struct ImportPipelineStatus {
std::atomic<int> num_active_threads; std::atomic<int> num_active_threads;
std::atomic<long long> next_progress_output;
ImportPipelineStatus(); ImportPipelineStatus();
}; };