mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
swarm/storage/localstore: add triggerGarbageCollection function
This commit is contained in:
parent
cee4004dff
commit
b5a0fd285f
1 changed files with 11 additions and 8 deletions
|
|
@ -55,10 +55,7 @@ func (db *DB) collectGarbageWorker() {
|
||||||
}
|
}
|
||||||
// check if another gc run is needed
|
// check if another gc run is needed
|
||||||
if !done {
|
if !done {
|
||||||
select {
|
db.triggerGarbageCollection()
|
||||||
case db.collectGarbageTrigger <- struct{}{}:
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if testHookCollectGarbage != nil {
|
if testHookCollectGarbage != nil {
|
||||||
|
|
@ -131,12 +128,18 @@ func (db *DB) incGCSize(count int64) {
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
if new >= db.capacity {
|
if new >= db.capacity {
|
||||||
|
db.triggerGarbageCollection()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// triggerGarbageCollection signals collectGarbageWorker
|
||||||
|
// to call collectGarbage.
|
||||||
|
func (db *DB) triggerGarbageCollection() {
|
||||||
select {
|
select {
|
||||||
case db.collectGarbageTrigger <- struct{}{}:
|
case db.collectGarbageTrigger <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var writeGCSizeDelay = 10 * time.Second
|
var writeGCSizeDelay = 10 * time.Second
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue