aboutsummaryrefslogtreecommitdiff
path: root/zenstore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-21 18:03:41 +0200
committerStefan Boberg <[email protected]>2021-10-21 18:03:41 +0200
commit3e824897aed32282ec9ee297e1cfc3efc5a8d251 (patch)
tree199d71e7314ecf7df577b4466f0d599b86c4dd08 /zenstore/include
parentAdded IsReady flag to ZenServerEntry (diff)
downloadzen-3e824897aed32282ec9ee297e1cfc3efc5a8d251.tar.xz
zen-3e824897aed32282ec9ee297e1cfc3efc5a8d251.zip
gc: Added GcStorage base class and hooked it up to CasGc
Diffstat (limited to 'zenstore/include')
-rw-r--r--zenstore/include/zenstore/CAS.h3
-rw-r--r--zenstore/include/zenstore/gc.h27
2 files changed, 24 insertions, 6 deletions
diff --git a/zenstore/include/zenstore/CAS.h b/zenstore/include/zenstore/CAS.h
index 738103f73..a387b905e 100644
--- a/zenstore/include/zenstore/CAS.h
+++ b/zenstore/include/zenstore/CAS.h
@@ -20,6 +20,7 @@
namespace zen {
class GcContext;
+class CasGc;
struct CasStoreConfiguration
{
@@ -107,7 +108,7 @@ protected:
uint64_t m_LastScrubTime = 0;
};
-ZENCORE_API CasStore* CreateCasStore();
+ZENCORE_API CasStore* CreateCasStore(CasGc& Gc);
void CAS_forcelink();
diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h
index 942355293..d51925a0c 100644
--- a/zenstore/include/zenstore/gc.h
+++ b/zenstore/include/zenstore/gc.h
@@ -33,10 +33,9 @@ private:
std::unique_ptr<GcState> m_State;
};
-
/** GC root contributor
- Higher level data structures provide roots for the garbage collector,
+ Higher level data structures provide roots for the garbage collector,
which ultimately determine what is garbage and what data we need to
retain.
@@ -48,24 +47,42 @@ public:
GcContributor(CasGc& Gc);
~GcContributor();
- virtual void GarbageCollect(GcContext& GcCtx) = 0;
+ virtual void GatherReferences(GcContext& GcCtx) = 0;
protected:
CasGc& m_Gc;
};
+/** GC storage provider
+ */
+
+class GcStorage
+{
+public:
+ GcStorage(CasGc& Gc);
+ ~GcStorage();
+
+ virtual void CollectGarbage(GcContext& GcCtrx) = 0;
+
+private:
+ CasGc& m_Gc;
+};
+
/** GC orchestrator
*/
class CasGc
{
public:
- CasGc(CasStore& Store);
+ CasGc();
~CasGc();
void AddGcContributor(GcContributor* Contributor);
void RemoveGcContributor(GcContributor* Contributor);
+ void AddGcStorage(GcStorage* Contributor);
+ void RemoveGcStorage(GcStorage* Contributor);
+
void CollectGarbage();
void OnNewCidReferences(std::span<IoHash> Hashes);
@@ -73,9 +90,9 @@ public:
void OnDroppedCidReferences(std::span<IoHash> Hashes);
private:
- CasStore& m_CasStore;
RwLock m_Lock;
std::vector<GcContributor*> m_GcContribs;
+ std::vector<GcStorage*> m_GcStorage;
};
} // namespace zen