pin

package
v4.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentPinner

type ConcurrentPinner struct {
	runtime.Pinner
	sync.Mutex
}

ConcurrentPinner is a Pinner that is safe for concurrent use by multiple goroutines.

func (*ConcurrentPinner) Pin

func (p *ConcurrentPinner) Pin(v any)

func (*ConcurrentPinner) Unpin

func (p *ConcurrentPinner) Unpin()

type Pinner

type Pinner interface {
	// Pin pins a Go object, preventing it from being moved or freed by the
	// garbage collector until the [Pinner.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.
	//
	// 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.
	Pin(any)

	// Unpin unpins all pinned objects of the [Pinner].
	Unpin()
}

A Pinner is a set of Go objects each pinned to a fixed location in memory. The [Pinner.Pin] method pins one object, while [Pinner.Unpin] unpins all pinned objects. See their comments for more information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL