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

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-05-31 13:56:35 +03:00 committed by LeL
parent 5073a37930
commit 0148209168

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()