浏览代码

Merge pull request #37 from vincentbernat/fix/atomic-alignment

ewma: ensure 64-bit alignment of uncounted
Richard Crowley 12 年之前
父节点
当前提交
debf646d00
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      ewma.go

+ 2 - 2
ewma.go

@@ -77,11 +77,11 @@ func (NilEWMA) Update(n int64) {}
 // of uncounted events and processes them on each tick.  It uses the
 // sync/atomic package to manage uncounted events.
 type StandardEWMA struct {
+	uncounted int64		// /!\ this should be the first member to ensure 64-bit alignment
 	alpha     float64
+	rate      float64
 	init      bool
 	mutex     sync.Mutex
-	rate      float64
-	uncounted int64
 }
 
 // Rate returns the moving average rate of events per second.