]> Cypherpunks repositories - gostls13.git/commitdiff
unique: use runtime.AddCleanup instead of runtime.SetFinalizer
authorCarlos Amedee <carlos@golang.org>
Fri, 14 Feb 2025 17:39:44 +0000 (12:39 -0500)
committerCarlos Amedee <carlos@golang.org>
Mon, 24 Feb 2025 17:11:32 +0000 (09:11 -0800)
Replace the usage of runtime.SetFinalizer with runtime.AddCleanup in
tests.

Updates #70907

Change-Id: I0d91b6af9643bde278215318f6176277373ddd19
Reviewed-on: https://go-review.googlesource.com/c/go/+/649458
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/unique/handle_test.go

index 4b70876029c81cafbc66c78e5904807b640d777c..c8fd20b4cb1952677e3ec752d3f45fbccce38dca 100644 (file)
@@ -124,12 +124,12 @@ func checkMapsFor[T comparable](t *testing.T, value T) {
 func TestMakeClonesStrings(t *testing.T) {
        s := strings.Clone("abcdefghijklmnopqrstuvwxyz") // N.B. Must be big enough to not be tiny-allocated.
        ran := make(chan bool)
-       runtime.SetFinalizer(unsafe.StringData(s), func(_ *byte) {
-               ran <- true
-       })
+       runtime.AddCleanup(unsafe.StringData(s), func(ch chan bool) {
+               ch <- true
+       }, ran)
        h := Make(s)
 
-       // Clean up s (hopefully) and run the finalizer.
+       // Clean up s (hopefully) and run the cleanup.
        runtime.GC()
 
        select {