diff options
author | Michael Muré <batolettre@gmail.com> | 2023-08-14 16:58:06 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2023-08-14 16:58:06 +0200 |
commit | 297e1931a7b5913275e8e9b0a46494d95e7e5e7c (patch) | |
tree | 5c5ef10f66bff4f9e6e3bbe87c70c02940bdbce3 /cache/with_snapshot.go | |
parent | f0167a1d6068d22af5ffff260e2848f7c14a71b3 (diff) | |
download | git-bug-bootstrap-rework-2.tar.gz git-bug-bootstrap-rework-2.zip |
WIP 2bootstrap-rework-2
Diffstat (limited to 'cache/with_snapshot.go')
-rw-r--r-- | cache/with_snapshot.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/cache/with_snapshot.go b/cache/with_snapshot.go index 674b6923b..47bad74ba 100644 --- a/cache/with_snapshot.go +++ b/cache/with_snapshot.go @@ -3,15 +3,16 @@ package cache import ( "sync" + "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/entity/dag" "github.com/MichaelMure/git-bug/repository" ) -var _ dag.Interface[dag.Snapshot, dag.OperationWithApply[dag.Snapshot]] = &withSnapshot[dag.Snapshot, dag.OperationWithApply[dag.Snapshot]]{} +var _ entity.Interface[entity.Snapshot, dag.OperationWithApply[entity.Snapshot]] = &withSnapshot[entity.Snapshot, dag.OperationWithApply[entity.Snapshot]]{} // withSnapshot encapsulate an entity and maintain a snapshot efficiently. -type withSnapshot[SnapT dag.Snapshot, OpT dag.OperationWithApply[SnapT]] struct { - dag.Interface[SnapT, OpT] +type withSnapshot[SnapT entity.Snapshot, OpT dag.OperationWithApply[SnapT]] struct { + entity.WithCommit[SnapT, OpT] mu sync.Mutex snap *SnapT } @@ -20,7 +21,7 @@ func (ws *withSnapshot[SnapT, OpT]) Compile() SnapT { ws.mu.Lock() defer ws.mu.Unlock() if ws.snap == nil { - snap := ws.Interface.Compile() + snap := ws.WithCommit.Compile() ws.snap = &snap } return *ws.snap @@ -31,7 +32,7 @@ func (ws *withSnapshot[SnapT, OpT]) Append(op OpT) { ws.mu.Lock() defer ws.mu.Unlock() - ws.Interface.Append(op) + ws.WithCommit.Append(op) if ws.snap == nil { return @@ -46,7 +47,7 @@ func (ws *withSnapshot[SnapT, OpT]) Commit(repo repository.ClockedRepo) error { ws.mu.Lock() defer ws.mu.Unlock() - err := ws.Interface.Commit(repo) + err := ws.WithCommit.Commit(repo) if err != nil { ws.snap = nil return err |