aboutsummaryrefslogtreecommitdiff
path: root/zenstore/gc.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-19 22:21:45 +0200
committerStefan Boberg <[email protected]>2021-10-19 22:21:45 +0200
commit483a40f2cf28b52c4447d5a98bcc7f79c50f426c (patch)
tree328c683489b92535a0d7094e7908d1d60f1df689 /zenstore/gc.cpp
parentgc: moved GcContect from CAS into gc files (diff)
downloadzen-483a40f2cf28b52c4447d5a98bcc7f79c50f426c.tar.xz
zen-483a40f2cf28b52c4447d5a98bcc7f79c50f426c.zip
cas: Hooked up GC to structured cache
Diffstat (limited to 'zenstore/gc.cpp')
-rw-r--r--zenstore/gc.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp
index e7c8f3a1a..c25ea344c 100644
--- a/zenstore/gc.cpp
+++ b/zenstore/gc.cpp
@@ -35,6 +35,18 @@ GcContext::ContributeCas(std::span<const IoHash> Cas)
//////////////////////////////////////////////////////////////////////////
+GcContributor::GcContributor(CasGc& Gc) : m_Gc(Gc)
+{
+ m_Gc.AddGcContributor(this);
+}
+
+GcContributor::~GcContributor()
+{
+ m_Gc.RemoveGcContributor(this);
+}
+
+//////////////////////////////////////////////////////////////////////////
+
CasGc::CasGc(CasStore& Store) : m_CasStore(Store)
{
}
@@ -43,13 +55,27 @@ CasGc::~CasGc()
{
}
+void
+CasGc::AddGcContributor(GcContributor* Contributor)
+{
+ RwLock::ExclusiveLockScope _(m_Lock);
+ m_GcContribs.push_back(Contributor);
+}
+
+void
+CasGc::RemoveGcContributor(GcContributor* Contributor)
+{
+ RwLock::ExclusiveLockScope _(m_Lock);
+ std::erase_if(m_GcContribs, [&](GcContributor* $) { return $ == Contributor; });
+}
+
void
CasGc::CollectGarbage()
{
}
void
-CasGc::OnNewReferences(std::span<IoHash> Hashes)
+CasGc::OnNewCidReferences(std::span<IoHash> Hashes)
{
ZEN_UNUSED(Hashes);
}