all: Use new Go 1.19 atomic types (#8772)

This commit is contained in:
greatroar
2023-02-07 12:07:34 +01:00
committed by GitHub
parent 882b711958
commit 38f2b34d29
19 changed files with 94 additions and 121 deletions
+3 -5
View File
@@ -628,7 +628,7 @@ func (w *walker) String() string {
// A byteCounter gets bytes added to it via Update() and then provides the
// Total() and one minute moving average Rate() in bytes per second.
type byteCounter struct {
total int64 // atomic, must remain 64-bit aligned
total atomic.Int64
metrics.EWMA
stop chan struct{}
}
@@ -658,13 +658,11 @@ func (c *byteCounter) ticker() {
}
func (c *byteCounter) Update(bytes int64) {
atomic.AddInt64(&c.total, bytes)
c.total.Add(bytes)
c.EWMA.Update(bytes)
}
func (c *byteCounter) Total() int64 {
return atomic.LoadInt64(&c.total)
}
func (c *byteCounter) Total() int64 { return c.total.Load() }
func (c *byteCounter) Close() {
close(c.stop)