From 9eaee38babed7cd08c07036622e5796e730e2186 Mon Sep 17 00:00:00 2001 From: Charlie Tonneslan Date: Sat, 16 May 2026 20:51:12 -0400 Subject: [PATCH] use CompareAndSwap instead of the deprecated CAS shim internally Bool.Toggle and Float32/Float64.Add still called their own deprecated CAS wrappers, which themselves just delegate to CompareAndSwap. Hop straight to CompareAndSwap so the internal code isn't waving its own deprecation warning at the user. Closes #158 Signed-off-by: Charlie Tonneslan --- bool_ext.go | 2 +- float32_ext.go | 2 +- float64_ext.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bool_ext.go b/bool_ext.go index a2e60e9..2a8b1e4 100644 --- a/bool_ext.go +++ b/bool_ext.go @@ -41,7 +41,7 @@ func boolToInt(b bool) uint32 { func (b *Bool) Toggle() (old bool) { for { old := b.Load() - if b.CAS(old, !old) { + if b.CompareAndSwap(old, !old) { return old } } diff --git a/float32_ext.go b/float32_ext.go index b0cd8d9..f52d281 100644 --- a/float32_ext.go +++ b/float32_ext.go @@ -32,7 +32,7 @@ func (f *Float32) Add(delta float32) float32 { for { old := f.Load() new := old + delta - if f.CAS(old, new) { + if f.CompareAndSwap(old, new) { return new } } diff --git a/float64_ext.go b/float64_ext.go index 48c52b0..ffed1f2 100644 --- a/float64_ext.go +++ b/float64_ext.go @@ -32,7 +32,7 @@ func (f *Float64) Add(delta float64) float64 { for { old := f.Load() new := old + delta - if f.CAS(old, new) { + if f.CompareAndSwap(old, new) { return new } }