do not leak Ticker in closed stats reporter

master
Oliver Tonnhofer 2013-11-25 09:12:41 +01:00
parent a4ea44acb1
commit 7e57c6047b
1 changed files with 6 additions and 4 deletions

View File

@ -103,16 +103,18 @@ func NewStatsReporterWithEstimate(counts *ElementCounts) *Statistics {
} }
func (s *Statistics) loop() { func (s *Statistics) loop() {
tick := time.Tick(500 * time.Millisecond) tick := time.NewTicker(500 * time.Millisecond)
tock := time.Tick(time.Minute) tock := time.NewTicker(time.Minute)
for { for {
select { select {
case <-s.done: case <-s.done:
tick.Stop()
tock.Stop()
s.counter.PrintStats() s.counter.PrintStats()
return return
case <-tock: case <-tock.C:
s.counter.PrintStats() s.counter.PrintStats()
case <-tick: case <-tick.C:
s.counter.PrintTick() s.counter.PrintTick()
s.counter.Tick() s.counter.Tick()
} }