[#1462] writecache: Use `Timer` instead of `Ticker` in `flush`

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
remotes/fyrchik/changelog
Evgenii Stratonikov 2022-05-31 13:56:35 +03:00 committed by LeL
parent 5073a37930
commit 0148209168
1 changed files with 5 additions and 2 deletions

View File

@ -44,11 +44,14 @@ func (c *cache) flushLoop() {
c.flushBigObjects()
}()
tick := time.NewTicker(defaultFlushInterval)
tt := time.NewTimer(defaultFlushInterval)
defer tt.Stop()
for {
select {
case <-tick.C:
case <-tt.C:
c.flush()
tt.Reset(defaultFlushInterval)
case <-c.closeCh:
c.log.Debug("waiting for workers to quit")
wg.Wait()