aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-11-01 16:50:17 +0100
committerStefan Boberg <[email protected]>2021-11-01 16:50:17 +0100
commit2400d988796b952d65296e518944f505e9a91cb1 (patch)
tree77995a76525debced2686ba8ea610a9c7fa9752b
parentMerged from main (diff)
downloadzen-2400d988796b952d65296e518944f505e9a91cb1.tar.xz
zen-2400d988796b952d65296e518944f505e9a91cb1.zip
gc: CollectGarbage implementation
-rw-r--r--zenstore/gc.cpp17
-rw-r--r--zenstore/include/zenstore/gc.h2
2 files changed, 18 insertions, 1 deletions
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp
index cb03f72ff..3395761d6 100644
--- a/zenstore/gc.cpp
+++ b/zenstore/gc.cpp
@@ -110,6 +110,23 @@ CasGc::RemoveGcStorage(GcStorage* Storage)
void
CasGc::CollectGarbage()
{
+ RwLock::SharedLockScope _(m_Lock);
+
+ // First gather reference set
+
+ GcContext GcCtx;
+
+ for (GcContributor* Contributor : m_GcContribs)
+ {
+ Contributor->GatherReferences(GcCtx);
+ }
+
+ // Then trim storage
+
+ for (GcStorage* Storage : m_GcStorage)
+ {
+ Storage->CollectGarbage(GcCtx);
+ }
}
void
diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h
index ef62158ce..d3092d91c 100644
--- a/zenstore/include/zenstore/gc.h
+++ b/zenstore/include/zenstore/gc.h
@@ -65,7 +65,7 @@ public:
GcStorage(CasGc& Gc);
~GcStorage();
- virtual void CollectGarbage(GcContext& GcCtrx) = 0;
+ virtual void CollectGarbage(GcContext& GcCtx) = 0;
private:
CasGc& m_Gc;