]> Cypherpunks repositories - gostls13.git/commitdiff
internal: convert calls to atomic type
authorcui fliter <imcusg@gmail.com>
Sun, 4 Sep 2022 14:55:00 +0000 (14:55 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 7 Sep 2022 20:54:43 +0000 (20:54 +0000)
For #53821

Change-Id: Iee8ccea714726bbb6a4b384887bb107c29b823a9
GitHub-Last-Rev: 119aad36245800115ea85b9748e61d7c75f20344
GitHub-Pull-Request: golang/go#54862
Reviewed-on: https://go-review.googlesource.com/c/go/+/428335
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/internal/singleflight/singleflight_test.go

index c2310375f7d732e8e05f271e067691f84eab5bbb..99713c9e149c08c0f4a87289634cc240c4aa355b 100644 (file)
@@ -44,9 +44,9 @@ func TestDoDupSuppress(t *testing.T) {
        var g Group
        var wg1, wg2 sync.WaitGroup
        c := make(chan string, 1)
-       var calls int32
+       var calls atomic.Int32
        fn := func() (any, error) {
-               if atomic.AddInt32(&calls, 1) == 1 {
+               if calls.Add(1) == 1 {
                        // First invocation.
                        wg1.Done()
                }
@@ -81,7 +81,7 @@ func TestDoDupSuppress(t *testing.T) {
        // least reached the line before the Do.
        c <- "bar"
        wg2.Wait()
-       if got := atomic.LoadInt32(&calls); got <= 0 || got >= n {
+       if got := calls.Load(); got <= 0 || got >= n {
                t.Errorf("number of calls = %d; want over 0 and less than %d", got, n)
        }
 }