aboutsummaryrefslogtreecommitdiff
path: root/zenserver/projectstore.h
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-10-10 09:12:03 +0200
committerGitHub <[email protected]>2022-10-10 00:12:03 -0700
commit1ef847b194e8c7b87cc8351ef7a048980b9f3f22 (patch)
tree53da7b1c5484b6c81f5a4fa14af4bc71a43feb45 /zenserver/projectstore.h
parent0.1.7 (removed duplicate line) (diff)
downloadzen-1ef847b194e8c7b87cc8351ef7a048980b9f3f22.tar.xz
zen-1ef847b194e8c7b87cc8351ef7a048980b9f3f22.zip
De/oplog gc lifetime (#178)
* Make sure we don't use invalidated iterators in projectstore.cpp * project store keeps track of project file and will garbage collect data for a project if the project file no longer exist * Implement GC of projects in project store - still need to fix lifetime issues for Project instances * Add INFO log if project file path is empty in projectstore * changelog
Diffstat (limited to 'zenserver/projectstore.h')
-rw-r--r--zenserver/projectstore.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/zenserver/projectstore.h b/zenserver/projectstore.h
index a15556cfa..91c0e1549 100644
--- a/zenserver/projectstore.h
+++ b/zenserver/projectstore.h
@@ -58,7 +58,7 @@ static_assert(IsPow2(sizeof(OplogEntry)));
package data split into separate chunks for bulk data, exports and header
information.
*/
-class ProjectStore : public RefCounted, public GcContributor
+class ProjectStore : public RefCounted, public GcStorage, public GcContributor
{
struct OplogStorage;
@@ -156,6 +156,7 @@ public:
std::filesystem::path RootDir;
std::string EngineRootDir;
std::string ProjectRootDir;
+ std::string ProjectFilePath;
Oplog* NewOplog(std::string_view OplogId);
Oplog* OpenOplog(std::string_view OplogId);
@@ -163,6 +164,7 @@ public:
void IterateOplogs(std::function<void(const Oplog&)>&& Fn) const;
void IterateOplogs(std::function<void(Oplog&)>&& Fn);
void DiscoverOplogs();
+ bool IsExpired() const;
Project(ProjectStore* PrjStore, CidStore& Store, std::filesystem::path BasePath);
~Project();
@@ -174,6 +176,7 @@ public:
void Scrub(ScrubContext& Ctx);
spdlog::logger& Log();
void GatherReferences(GcContext& GcCtx);
+ void Delete();
private:
ProjectStore* m_ProjectStore;
@@ -192,8 +195,9 @@ public:
std::string_view ProjectId,
std::string_view RootDir,
std::string_view EngineRootDir,
- std::string_view ProjectRootDir);
- void DeleteProject(std::string_view ProjectId);
+ std::string_view ProjectRootDir,
+ std::string_view ProjectFilePath);
+ void DeleteProject(std::string_view ProjectId, bool OnlyDeleteIfExpired);
bool Exists(std::string_view ProjectId);
void Flush();
void Scrub(ScrubContext& Ctx);
@@ -203,7 +207,9 @@ public:
spdlog::logger& Log() { return m_Log; }
const std::filesystem::path& BasePath() const { return m_ProjectBasePath; }
- virtual void GatherReferences(GcContext& GcCtx) override;
+ virtual void GatherReferences(GcContext& GcCtx) override;
+ virtual void CollectGarbage(GcContext& GcCtx) override;
+ virtual GcStorageSize StorageSize() const override;
private:
spdlog::logger& m_Log;