Skip to content

Commit

Permalink
PosixSourceAccessor: Use SharedSync
Browse files Browse the repository at this point in the history
edolstra committed Jun 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 2f39caf commit fd9e494
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libutil/posix-source-accessor.cc
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit fd9e494

Please sign in to comment.