Skip to content

Commit 9c2ab20

Browse files
qiulaidongfenggopherbot
authored andcommitted
internal/fmtsort: makeChans pin pointer
Complete TODO. For #49431 Change-Id: I1399205e430ebd83182c3e0c4becf1fde32d433e GitHub-Last-Rev: 02cdea7 GitHub-Pull-Request: #62673 Reviewed-on: https://go-review.googlesource.com/c/go/+/528796 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Commit-Queue: Keith Randall <khr@golang.org> Run-TryBot: qiulaidongfeng <2645477756@qq.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
1 parent 214ce28 commit 9c2ab20

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/internal/fmtsort/sort_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"internal/fmtsort"
1010
"math"
1111
"reflect"
12+
"runtime"
1213
"sort"
1314
"strings"
1415
"testing"
@@ -190,12 +191,15 @@ func sprintKey(key reflect.Value) string {
190191
var (
191192
ints [3]int
192193
chans = makeChans()
194+
pin runtime.Pinner
193195
)
194196

195197
func makeChans() []chan int {
196198
cs := []chan int{make(chan int), make(chan int), make(chan int)}
197199
// Order channels by address. See issue #49431.
198-
// TODO: pin these pointers once pinning is available (#46787).
200+
for i := range cs {
201+
pin.Pin(reflect.ValueOf(cs[i]).UnsafePointer())
202+
}
199203
sort.Slice(cs, func(i, j int) bool {
200204
return uintptr(reflect.ValueOf(cs[i]).UnsafePointer()) < uintptr(reflect.ValueOf(cs[j]).UnsafePointer())
201205
})

0 commit comments

Comments
 (0)