mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-05 23:35:48 +08:00
自动在空闲时间执行定时任务
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package counters
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/goman"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
|
||||
memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem"
|
||||
syncutils "github.com/TeaOSLab/EdgeNode/internal/utils/sync"
|
||||
@@ -56,11 +57,11 @@ func (this *Counter[T]) WithGC() *Counter[T] {
|
||||
return this
|
||||
}
|
||||
this.gcTicker = time.NewTicker(1 * time.Second)
|
||||
go func() {
|
||||
goman.New(func() {
|
||||
for range this.gcTicker.C {
|
||||
this.GC()
|
||||
}
|
||||
}()
|
||||
})
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user