github.com/aristanetworks/goarista@v0.0.0-20240514173732-cca2755bbd44/monitor/types.go (about) 1 // Copyright (c) 2015 Arista Networks, Inc. 2 // Use of this source code is governed by the Apache License 2.0 3 // that can be found in the COPYING file. 4 5 package monitor 6 7 import ( 8 "strconv" 9 "sync/atomic" 10 ) 11 12 // Uint is a 64-bit unsigned integer variable that satisfies the Var interface. 13 type Uint struct { 14 i uint64 15 } 16 17 func (v *Uint) String() string { 18 return strconv.FormatUint(atomic.LoadUint64(&v.i), 10) 19 } 20 21 // Add delta 22 func (v *Uint) Add(delta uint64) { 23 atomic.AddUint64(&v.i, delta) 24 } 25 26 // Get the uint64 stored in the Uint 27 func (v *Uint) Get() uint64 { 28 return atomic.LoadUint64(&v.i) 29 } 30 31 // Set value 32 func (v *Uint) Set(value uint64) { 33 atomic.StoreUint64(&v.i, value) 34 }