aboutsummaryrefslogtreecommitdiff
path: root/zenstore/gc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenstore/gc.cpp')
-rw-r--r--zenstore/gc.cpp71
1 files changed, 70 insertions, 1 deletions
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp
index bfb8f015e..612cceed9 100644
--- a/zenstore/gc.cpp
+++ b/zenstore/gc.cpp
@@ -1,9 +1,52 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include <zenstore/gc.h>
+#include <zenstore/CAS.h>
namespace zen {
+//////////////////////////////////////////////////////////////////////////
+
+struct GcContext::GcState
+{
+ CasChunkSet m_CasChunks;
+ CasChunkSet m_CidChunks;
+};
+
+GcContext::GcContext() : m_State(std::make_unique<GcState>())
+{
+}
+
+GcContext::~GcContext()
+{
+}
+
+void
+GcContext::ContributeCids(std::span<const IoHash> Cids)
+{
+ m_State->m_CidChunks.AddChunksToSet(Cids);
+}
+
+void
+GcContext::ContributeCas(std::span<const IoHash> Cas)
+{
+ m_State->m_CasChunks.AddChunksToSet(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)
{
}
@@ -12,13 +55,39 @@ 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);
+}
+
+void
+CasGc::OnCommittedCidReferences(std::span<IoHash> Hashes)
+{
+ ZEN_UNUSED(Hashes);
+}
+
+void
+CasGc::OnDroppedCidReferences(std::span<IoHash> Hashes)
{
ZEN_UNUSED(Hashes);
}