github.com/puellanivis/breton@v0.2.16/lib/metrics/internal/atomic/counter.go (about) 1 // Package atomic (DO NOT USE) is a baseline implementation to replace float64 metrics used internally by prometheus. 2 package atomic 3 4 import ( 5 "sync/atomic" 6 ) 7 8 // Counter is a simple atomic monotonously-increasing counter. 9 type Counter uint64 10 11 // Inc increments the Counter by one (1). 12 func (c *Counter) Inc() { 13 c.Add(1) 14 } 15 16 // Add increments the Counter by a given integer (must be non-negative). 17 func (c *Counter) Add(delta uint64) { 18 atomic.AddUint64((*uint64)(c), delta) 19 } 20 21 // Get returns a momentary value of the Counter. 22 func (c *Counter) Get() uint64 { 23 return atomic.LoadUint64((*uint64)(c)) 24 }