Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
swarm/storage/localstore: add triggerGarbageCollection function
Browse files Browse the repository at this point in the history
  • Loading branch information
janos committed Dec 19, 2018
1 parent cee4004 commit b5a0fd2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions swarm/storage/localstore/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ func (db *DB) collectGarbageWorker() {
}
// check if another gc run is needed
if !done {
select {
case db.collectGarbageTrigger <- struct{}{}:
default:
}
db.triggerGarbageCollection()
}

if testHookCollectGarbage != nil {
Expand Down Expand Up @@ -131,10 +128,16 @@ func (db *DB) incGCSize(count int64) {
default:
}
if new >= db.capacity {
select {
case db.collectGarbageTrigger <- struct{}{}:
default:
}
db.triggerGarbageCollection()
}
}

// triggerGarbageCollection signals collectGarbageWorker
// to call collectGarbage.
func (db *DB) triggerGarbageCollection() {
select {
case db.collectGarbageTrigger <- struct{}{}:
default:
}
}

Expand Down

0 comments on commit b5a0fd2

Please sign in to comment.