fix race in testutil Accumulator.Wait() (#2598)
This commit is contained in:
parent
71cdcee8b2
commit
f13686bdf7
|
@ -43,9 +43,9 @@ func (a *Accumulator) NMetrics() uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Accumulator) ClearMetrics() {
|
func (a *Accumulator) ClearMetrics() {
|
||||||
atomic.StoreUint64(&a.nMetrics, 0)
|
|
||||||
a.Lock()
|
a.Lock()
|
||||||
defer a.Unlock()
|
defer a.Unlock()
|
||||||
|
atomic.StoreUint64(&a.nMetrics, 0)
|
||||||
a.Metrics = make([]*Metric, 0)
|
a.Metrics = make([]*Metric, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ func (a *Accumulator) AddFields(
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
timestamp ...time.Time,
|
timestamp ...time.Time,
|
||||||
) {
|
) {
|
||||||
atomic.AddUint64(&a.nMetrics, 1)
|
|
||||||
a.Lock()
|
a.Lock()
|
||||||
defer a.Unlock()
|
defer a.Unlock()
|
||||||
|
atomic.AddUint64(&a.nMetrics, 1)
|
||||||
if a.Cond != nil {
|
if a.Cond != nil {
|
||||||
a.Cond.Broadcast()
|
a.Cond.Broadcast()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue