1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

PosixSourceAccessor: Use SharedSync

This commit is contained in:
Eelco Dolstra 2024-06-05 22:24:00 +02:00
parent 2f39caf180
commit fd9e49480a

View file

@ -90,14 +90,14 @@ bool PosixSourceAccessor::pathExists(const CanonPath & path)
std::optional<struct stat> PosixSourceAccessor::cachedLstat(const CanonPath & path)
{
static Sync<std::unordered_map<Path, std::optional<struct stat>>> _cache;
static SharedSync<std::unordered_map<Path, std::optional<struct stat>>> _cache;
// Note: we convert std::filesystem::path to Path because the
// former is not hashable on libc++.
Path absPath = makeAbsPath(path).string();
{
auto cache(_cache.lock());
auto cache(_cache.read());
auto i = cache->find(absPath);
if (i != cache->end()) return i->second;
}