浏览代码

Add missing lock around float64 read.

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

+ 2 - 0
ewma.go

@@ -56,6 +56,8 @@ func NewEWMA15() *StandardEWMA {
 
 
 // Return the moving average rate of events per second.
 // Return the moving average rate of events per second.
 func (a *StandardEWMA) Rate() float64 {
 func (a *StandardEWMA) Rate() float64 {
+	a.mutex.Lock()
+	defer a.mutex.Unlock()
 	return a.rate * float64(1e9)
 	return a.rate * float64(1e9)
 }
 }