diff options
| author | Stefan Boberg <[email protected]> | 2021-10-21 18:03:41 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-10-21 18:03:41 +0200 |
| commit | 3e824897aed32282ec9ee297e1cfc3efc5a8d251 (patch) | |
| tree | 199d71e7314ecf7df577b4466f0d599b86c4dd08 /zenstore/include | |
| parent | Added IsReady flag to ZenServerEntry (diff) | |
| download | zen-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.h | 3 | ||||
| -rw-r--r-- | zenstore/include/zenstore/gc.h | 27 |
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 |