aboutsummaryrefslogtreecommitdiff
path: root/zenstore/include
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/include
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/include')
-rw-r--r--zenstore/include/zenstore/CAS.h1
-rw-r--r--zenstore/include/zenstore/gc.h26
2 files changed, 24 insertions, 3 deletions
diff --git a/zenstore/include/zenstore/CAS.h b/zenstore/include/zenstore/CAS.h
index dc7e260ab..738103f73 100644
--- a/zenstore/include/zenstore/CAS.h
+++ b/zenstore/include/zenstore/CAS.h
@@ -100,6 +100,7 @@ public:
virtual void FilterChunks(CasChunkSet& InOutChunks) = 0;
virtual void Flush() = 0;
virtual void Scrub(ScrubContext& Ctx) = 0;
+ virtual void GarbageCollect(GcContext& GcCtx) = 0;
protected:
CasStoreConfiguration m_Config;
diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h
index 33a43f4d2..dda33c9eb 100644
--- a/zenstore/include/zenstore/gc.h
+++ b/zenstore/include/zenstore/gc.h
@@ -3,12 +3,14 @@
#pragma once
#include <zencore/iohash.h>
+#include <zencore/thread.h>
#include <span>
namespace zen {
class CasStore;
+class CasGc;
struct IoHash;
/** Garbage Collection context object
@@ -29,8 +31,20 @@ private:
std::unique_ptr<GcState> m_State;
};
+class GcContributor
+{
+public:
+ GcContributor(CasGc& Gc);
+ ~GcContributor();
+
+ virtual void GarbageCollect(GcContext& GcCtx) = 0;
+
+protected:
+ CasGc& m_Gc;
+};
+
/** GC
- */
+ */
class CasGc
{
@@ -38,12 +52,18 @@ public:
CasGc(CasStore& Store);
~CasGc();
+ void AddGcContributor(GcContributor* Contributor);
+ void RemoveGcContributor(GcContributor* Contributor);
+
void CollectGarbage();
- void OnNewReferences(std::span<IoHash> Hashes);
+ void OnNewCidReferences(std::span<IoHash> Hashes);
private:
- CasStore& m_CasStore;
+ CasStore& m_CasStore;
+ RwLock m_Lock;
+ std::vector<GcContributor*> m_GcContribs;
};
} // namespace zen
+