From 6980c3e277ca6de06ab9a2a9146d343f4922a75d Mon Sep 17 00:00:00 2001 From: sharnoff Date: Sun, 5 Feb 2023 19:45:37 -0800 Subject: [PATCH] Fix util.AtomicMax comment --- pkg/util/arith.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/util/arith.go b/pkg/util/arith.go index b5c690770..33bcd74af 100644 --- a/pkg/util/arith.go +++ b/pkg/util/arith.go @@ -47,9 +47,11 @@ type AtomicInt[I any] interface { // AtomicMax atomically sets a to the maximum of *a and i, returning the old value at a. // -// Eventually, one would *hope* that go could add atomic maximum (and minimum), so we don't need -// this function (there are some ISAs that support such instructions). In the meantime though, this -// tends to be pretty useful - event though it's not wait-free. +// On ISAs without atomic maximum/minimum instructions, a fallback is typically implemented as the +// Load + CompareAndSwap loop that this function uses. At time of writing (Go 1.20), the Go standard +// library does not include atomic maximum/minimum functions. +// +// This function is lock-free but not wait-free. func AtomicMax[A AtomicInt[I], I constraints.Integer](a A, i I) I { for { current := a.Load()