aboutsummaryrefslogtreecommitdiff
path: root/zenstore/gc.cpp
blob: 612cceed9c421bc3a2d2efe55c4bfa70f0c6adc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright Epic Games, Inc. All Rights Reserved.

#include <zenstore/gc.h>
#include <zenstore/CAS.h>

namespace zen {

//////////////////////////////////////////////////////////////////////////

struct GcContext::GcState
{
	CasChunkSet m_CasChunks;
	CasChunkSet m_CidChunks;
};

GcContext::GcContext() : m_State(std::make_unique<GcState>())
{
}

GcContext::~GcContext()
{
}

void
GcContext::ContributeCids(std::span<const IoHash> Cids)
{
	m_State->m_CidChunks.AddChunksToSet(Cids);
}

void
GcContext::ContributeCas(std::span<const IoHash> Cas)
{
	m_State->m_CasChunks.AddChunksToSet(Cas);
}

//////////////////////////////////////////////////////////////////////////

GcContributor::GcContributor(CasGc& Gc) : m_Gc(Gc)
{
	m_Gc.AddGcContributor(this);
}

GcContributor::~GcContributor()
{
	m_Gc.RemoveGcContributor(this);
}

//////////////////////////////////////////////////////////////////////////

CasGc::CasGc(CasStore& Store) : m_CasStore(Store)
{
}

CasGc::~CasGc()
{
}

void 
CasGc::AddGcContributor(GcContributor* Contributor)
{
	RwLock::ExclusiveLockScope _(m_Lock);
	m_GcContribs.push_back(Contributor);
}

void 
CasGc::RemoveGcContributor(GcContributor* Contributor)
{
	RwLock::ExclusiveLockScope _(m_Lock);
	std::erase_if(m_GcContribs, [&](GcContributor* $) { return $ == Contributor; });
}

void
CasGc::CollectGarbage()
{
}

void
CasGc::OnNewCidReferences(std::span<IoHash> Hashes)
{
	ZEN_UNUSED(Hashes);
}

void
CasGc::OnCommittedCidReferences(std::span<IoHash> Hashes)
{
	ZEN_UNUSED(Hashes);
}

void
CasGc::OnDroppedCidReferences(std::span<IoHash> Hashes)
{
	ZEN_UNUSED(Hashes);
}

}  // namespace zen