From 734a7ff5e37aa36b799a11d47ab210b81ab11d15 Mon Sep 17 00:00:00 2001 From: Arturas Moskvinas Date: Mon, 10 Oct 2022 20:23:59 +0300 Subject: [PATCH] Terminate timeloop faster for m3 (#185) --- m3/reporter.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/m3/reporter.go b/m3/reporter.go index 23cf39da..24e80d3e 100644 --- a/m3/reporter.go +++ b/m3/reporter.go @@ -692,9 +692,15 @@ func (r *reporter) reportInternalMetrics() { } func (r *reporter) timeLoop() { + t := time.NewTicker(_timeResolution) + defer t.Stop() for !r.done.Load() { r.now.Store(time.Now().UnixNano()) - time.Sleep(_timeResolution) + select { + case <-t.C: + case <-r.donech: + return + } } }