From 44dcfa3326d5fa143299f90171c3cd51b440b741 Mon Sep 17 00:00:00 2001 From: Per Larsson Date: Mon, 3 Jan 2022 13:18:12 +0100 Subject: Changed timestamp to atomic int64. --- zenserver/cache/structuredcachestore.cpp | 41 +++++++++++++++----------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'zenserver/cache/structuredcachestore.cpp') diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index a1a30e4af..e74becb3a 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -333,11 +333,11 @@ ZenCacheMemoryLayer::TotalSize() const void ZenCacheMemoryLayer::CacheBucket::Scrub(ScrubContext& Ctx) { - RwLock::SharedLockScope _(m_bucketLock); + RwLock::SharedLockScope _(m_BucketLock); std::vector BadHashes; - for (auto& Kv : m_cacheMap) + for (auto& Kv : m_CacheMap) { if (Kv.first != IoHash::HashBuffer(Kv.second.Payload)) { @@ -354,8 +354,8 @@ ZenCacheMemoryLayer::CacheBucket::Scrub(ScrubContext& Ctx) void ZenCacheMemoryLayer::CacheBucket::GatherAccessTimes(std::vector& AccessTimes) { - RwLock::SharedLockScope _(m_bucketLock); - std::transform(m_cacheMap.begin(), m_cacheMap.end(), std::back_inserter(AccessTimes), [](const auto& Kv) { + RwLock::SharedLockScope _(m_BucketLock); + std::transform(m_CacheMap.begin(), m_CacheMap.end(), std::back_inserter(AccessTimes), [](const auto& Kv) { return access_tracking::KeyAccessTime{.Key = Kv.first, .LastAccess = Kv.second.LastAccess}; }); } @@ -363,28 +363,27 @@ ZenCacheMemoryLayer::CacheBucket::GatherAccessTimes(std::vector(MaxFileOffset, Entry.Location.Offset() + Entry.Location.Size()); @@ -583,9 +582,7 @@ ZenCacheDiskLayer::CacheBucket::Get(const IoHash& HashKey, ZenCacheValue& OutVal if (auto It = m_Index.find(HashKey); It != m_Index.end()) { IndexEntry& Entry = It.value(); - Entry.LastAccess = GcClock::TickCount(); - { - } + Entry.LastAccess.store(GcClock::TickCount(), std::memory_order_relaxed); if (GetInlineCacheValue(Entry.Location, OutValue)) { @@ -641,7 +638,7 @@ ZenCacheDiskLayer::CacheBucket::Put(const IoHash& HashKey, const ZenCacheValue& // content hash to the index entry IndexEntry& Entry = It.value(); Entry.Location = Loc; - Entry.LastAccess = GcClock::TickCount(); + Entry.LastAccess.store(GcClock::TickCount(), std::memory_order_relaxed); } m_SlogFile.Append({.Key = HashKey, .Location = Loc}); @@ -1023,7 +1020,7 @@ ZenCacheDiskLayer::CacheBucket::UpdateAccessTimes(const std::vector