浏览代码

Mariano's right: clear the sample inside the lock.

Richard Crowley 12 年之前
父节点
当前提交
9179d9e3e3
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      histogram.go

+ 1 - 1
histogram.go

@@ -50,12 +50,12 @@ func NewHistogram(s Sample) *StandardHistogram {
 
 
 // Clear the histogram.
 // Clear the histogram.
 func (h *StandardHistogram) Clear() {
 func (h *StandardHistogram) Clear() {
-	h.s.Clear()
 	h.mutex.Lock()
 	h.mutex.Lock()
 	defer h.mutex.Unlock()
 	defer h.mutex.Unlock()
 	h.count = 0
 	h.count = 0
 	h.max = math.MinInt64
 	h.max = math.MinInt64
 	h.min = math.MaxInt64
 	h.min = math.MaxInt64
+	h.s.Clear()
 	h.sum = 0
 	h.sum = 0
 	h.variance = [...]float64{-1.0, 0.0}
 	h.variance = [...]float64{-1.0, 0.0}
 }
 }