Update delete loop
This commit is contained in:
parent
b0f684769a
commit
bf76836a21
@ -2,8 +2,11 @@ package settings
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
const deleteLoopInterval = time.Second * 20
|
||||
|
||||
type deleteLoop struct {
|
||||
deleteCtx context.Context
|
||||
deleteCancel context.CancelFunc
|
||||
@ -30,12 +33,17 @@ func (dl *deleteLoop) Run() {
|
||||
func (dl *deleteLoop) loop() {
|
||||
defer close(dl.loopDone)
|
||||
dl.deleteFunc()
|
||||
ticker := time.NewTicker(deleteLoopInterval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-dl.deleteCtx.Done():
|
||||
return
|
||||
case <-dl.deleteChan:
|
||||
dl.deleteFunc()
|
||||
ticker.Reset(deleteLoopInterval)
|
||||
case <-ticker.C:
|
||||
dl.deleteFunc()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user