[#1462] writecache: Use Timer
instead of Ticker
in flush
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
5073a37930
commit
0148209168
1 changed files with 5 additions and 2 deletions
|
@ -44,11 +44,14 @@ func (c *cache) flushLoop() {
|
||||||
c.flushBigObjects()
|
c.flushBigObjects()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
tick := time.NewTicker(defaultFlushInterval)
|
tt := time.NewTimer(defaultFlushInterval)
|
||||||
|
defer tt.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-tick.C:
|
case <-tt.C:
|
||||||
c.flush()
|
c.flush()
|
||||||
|
tt.Reset(defaultFlushInterval)
|
||||||
case <-c.closeCh:
|
case <-c.closeCh:
|
||||||
c.log.Debug("waiting for workers to quit")
|
c.log.Debug("waiting for workers to quit")
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
Loading…
Reference in a new issue