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() {
tick := time.Tick(500 * time.Millisecond)
tock := time.Tick(time.Minute)
tick := time.NewTicker(500 * time.Millisecond)
tock := time.NewTicker(time.Minute)
for {
select {
case <-s.done:
tick.Stop()
tock.Stop()
s.counter.PrintStats()
return
case <-tock:
case <-tock.C:
s.counter.PrintStats()
case <-tick:
case <-tick.C:
s.counter.PrintTick()
s.counter.Tick()
}