Skip to content

Commit

Permalink
Merge pull request #39 from wreulicke/patch-2
Browse files Browse the repository at this point in the history
Return newValue from SingleMeasurement#add
  • Loading branch information
platinummonkey committed Sep 14, 2020
2 parents fe4e855 + 494a182 commit 6b67d23
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions measurements/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ type SingleMeasurement struct {
// Add a single sample and update the internal state.
func (m *SingleMeasurement) Add(value float64) (float64, bool) {
m.mu.Lock()
oldValue := float64(m.value)
defer m.mu.Unlock()
m.value = value
m.mu.Unlock()
return oldValue, true
return m.value, true
}

// Get the current value.
Expand Down

0 comments on commit 6b67d23

Please sign in to comment.