[clangd] Extract per-dir CDB cache to its own threadsafe class. NFC
authorSam McCall <sam.mccall@gmail.com>
Tue, 1 Dec 2020 11:48:41 +0000 (12:48 +0100)
committerSam McCall <sam.mccall@gmail.com>
Wed, 9 Dec 2020 16:40:12 +0000 (17:40 +0100)
commit634a377bd8cbaa515a58295cfd85dcb6a21381c1
tree6223a869416edd39d390a15baf6e99bfdef0ee8e
parent717b0da7a6ef0a8a03d7296324f76132118fcf54
[clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

This is a step towards making compile_commands.json reloadable.

The idea is:
 - in addition to rare CDB loads we're soon going to have somewhat-rare CDB
   reloads and fairly-common stat() of files to validate the CDB
 - so stop doing all our work under a big global lock, instead using it to
   acquire per-directory structures with their own locks
 - each directory can be refreshed from disk every N seconds, like filecache
 - avoid locking these at all in the most common case: directory has no CDB

Differential Revision: https://reviews.llvm.org/D92381
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.h