Explorar o código

Do not export methods from sync.Mutex on gauges.

Richard Crowley %!s(int64=11) %!d(string=hai) anos
pai
achega
37df06ff62
Modificáronse 1 ficheiros con 5 adicións e 5 borrados
  1. 5 5
      gauge_float64.go

+ 5 - 5
gauge_float64.go

@@ -67,8 +67,8 @@ func (NilGaugeFloat64) Value() float64 { return 0.0 }
 // StandardGaugeFloat64 is the standard implementation of a GaugeFloat64 and uses
 // StandardGaugeFloat64 is the standard implementation of a GaugeFloat64 and uses
 // sync.Mutex to manage a single float64 value.
 // sync.Mutex to manage a single float64 value.
 type StandardGaugeFloat64 struct {
 type StandardGaugeFloat64 struct {
+	mutex sync.Mutex
 	value float64
 	value float64
-	sync.Mutex
 }
 }
 
 
 // Snapshot returns a read-only copy of the gauge.
 // Snapshot returns a read-only copy of the gauge.
@@ -78,14 +78,14 @@ func (g *StandardGaugeFloat64) Snapshot() GaugeFloat64 {
 
 
 // Update updates the gauge's value.
 // Update updates the gauge's value.
 func (g *StandardGaugeFloat64) Update(v float64) {
 func (g *StandardGaugeFloat64) Update(v float64) {
-	g.Lock()
-	defer g.Unlock()
+	g.mutex.Lock()
+	defer g.mutex.Unlock()
 	g.value = v
 	g.value = v
 }
 }
 
 
 // Value returns the gauge's current value.
 // Value returns the gauge's current value.
 func (g *StandardGaugeFloat64) Value() float64 {
 func (g *StandardGaugeFloat64) Value() float64 {
-	g.Lock()
-	defer g.Unlock()
+	g.mutex.Lock()
+	defer g.mutex.Unlock()
 	return g.value
 	return g.value
 }
 }