From 01482091687b9740045c1db3ba481859a549b622 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 31 May 2022 13:56:35 +0300 Subject: [PATCH] [#1462] writecache: Use `Timer` instead of `Ticker` in `flush` Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/writecache/flush.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/local_object_storage/writecache/flush.go b/pkg/local_object_storage/writecache/flush.go index fa1ac903..8dfed500 100644 --- a/pkg/local_object_storage/writecache/flush.go +++ b/pkg/local_object_storage/writecache/flush.go @@ -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()