aboutsummaryrefslogtreecommitdiff
path: root/zenstore/include
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-11-29 12:55:08 +0100
committerPer Larsson <[email protected]>2021-11-29 12:55:08 +0100
commit9a8e2c8d905bc1e5b62c6f5e246d2574a645b73e (patch)
treefb6cd0492812dd8ea99ba3dde27cc2b49dd978dc /zenstore/include
parentMerged main. (diff)
downloadzen-9a8e2c8d905bc1e5b62c6f5e246d2574a645b73e.tar.xz
zen-9a8e2c8d905bc1e5b62c6f5e246d2574a645b73e.zip
Moved GC to background thread and added endpoint to trigger/status GC.
Diffstat (limited to 'zenstore/include')
-rw-r--r--zenstore/include/zenstore/gc.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h
index 560642803..8efe933a0 100644
--- a/zenstore/include/zenstore/gc.h
+++ b/zenstore/include/zenstore/gc.h
@@ -5,8 +5,9 @@
#include <zencore/iohash.h>
#include <zencore/thread.h>
-#include <span>
+#include <atomic>
#include <functional>
+#include <span>
#define ZEN_USE_REF_TRACKING 0 // This is not currently functional
@@ -107,4 +108,23 @@ private:
CidStore* m_CidStore;
};
+enum class GcStatus : uint32_t
+{
+ kIdle,
+ kRunning
+};
+
+class Gc
+{
+public:
+ bool Trigger();
+ CasGc& Cas() { return m_CasGc; }
+ GcStatus Status() const { return static_cast<GcStatus>(m_Status.load()); }
+
+private:
+ CasGc m_CasGc;
+ std::jthread m_GcThread;
+ std::atomic_uint32_t m_Status;
+};
+
} // namespace zen