Skip to content

Commit

Permalink
Spin IncludeComplete's destructor until scanning completes (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeszekSwirski authored and MaskRay committed Oct 24, 2019
1 parent fb02b0e commit 0b53720
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/include_complete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ CompletionItem BuildCompletionItem(const std::string &path,
IncludeComplete::IncludeComplete(Project *project)
: is_scanning(false), project_(project) {}

IncludeComplete::~IncludeComplete() {
// Spin until the scanning has completed.
while (is_scanning.load())
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

void IncludeComplete::Rescan() {
if (is_scanning || LLVM_VERSION_MAJOR >= 8)
return;
Expand Down
1 change: 1 addition & 0 deletions src/include_complete.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct Project;

struct IncludeComplete {
IncludeComplete(Project *project);
~IncludeComplete();

// Starts scanning directories. Clears existing cache.
void Rescan();
Expand Down

0 comments on commit 0b53720

Please sign in to comment.