From 451e4727ec825a7ce6f6e6f82761ff90c33fec83 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Sat, 16 Sep 2023 15:22:44 +1000 Subject: [PATCH] runtime: reword the documentation for Pinner I found the documentation for Pinner itself to contain too little information. Rewrite it to give a summary and redirect to the relevant methods. Also reformat the ragged comment for Pin. Change-Id: I9c786817f43dfc9c72178127c141c35dae221104 Reviewed-on: https://go-review.googlesource.com/c/go/+/528855 Reviewed-by: Ian Lance Taylor Reviewed-by: Matthew Dempsky TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor --- src/runtime/pinner.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/runtime/pinner.go b/src/runtime/pinner.go index eb62a0fd53..c0db91eba8 100644 --- a/src/runtime/pinner.go +++ b/src/runtime/pinner.go @@ -9,9 +9,9 @@ import ( "unsafe" ) -// A Pinner is a set of pinned Go objects. An object can be pinned with -// the Pin method and all pinned objects of a Pinner can be unpinned with the -// Unpin method. +// A Pinner is a set of Go objects each pinned to a fixed location in memory. The +// [Pin] method pins one object, while [Unpin] unpins all pinned objects. See their +// comments for more information. type Pinner struct { *pinner } @@ -19,11 +19,10 @@ type Pinner struct { // Pin pins a Go object, preventing it from being moved or freed by the garbage // collector until the Unpin method has been called. // -// A pointer to a pinned -// object can be directly stored in C memory or can be contained in Go memory -// passed to C functions. If the pinned object itself contains pointers to Go -// objects, these objects must be pinned separately if they are going to be -// accessed from C code. +// A pointer to a pinned object can be directly stored in C memory or can be +// contained in Go memory passed to C functions. If the pinned object itself +// contains pointers to Go objects, these objects must be pinned separately if they +// are going to be accessed from C code. // // The argument must be a pointer of any type or an unsafe.Pointer. // It's safe to call Pin on non-Go pointers, in which case Pin will do nothing. -- 2.50.0