This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix async index loading (from r341376).
ClosedPublic

Authored by sammccall on Sep 5 2018, 1:09 AM.

Details

Summary

This wasn't actually async (due to std::future destructor blocking).
If it were, we would have clean shutdown issues if main returned
and destroyed Placeholder before the thread is done with it.

We could attempt to avoid any blocking by using shared_ptr or weak_ptr tricks so
the thread can detect Placeholder's destruction, but there are other potential
issues (e.g. loadIndex does tracing, and we'll destroy the tracer...)
Instead, once LSPServer::run returns, we wait for the index to finish loading
before exiting. Performance is not critical in this situation.

Event Timeline

sammccall created this revision.Sep 5 2018, 1:09 AM
sammccall updated this revision to Diff 164012.Sep 5 2018, 4:41 AM

Don't load index asynchronously if -run-synchronously is passed.

Nothing needs this today, but it's less surprising behavior.

This revision is now accepted and ready to land.Sep 6 2018, 2:46 AM
This revision was automatically updated to reflect the committed changes.