keepalive

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package keepalive provides a simple Acquire and Release mechanism to make sure data is kept alive in between.

This is used to access data that is not managed by Go, and hence the GC has no way of knowing if its in use.

Example: the code guarantees that `resource` is being kept alive, and `data` is valid until released, and hence `data` (presumably Go GC doesn't know about it) can be safely accessed.

ref := keeplive.Acquire(resource)
defer ref.Release()
data := resource.C_data
...

The package also provides ListAcquired method to investigate leaks (resources allocated but not released).

Index

Constants

View Source
const EndOfList = KeepAlive(-1)
View Source
const InitialFreeSlots = 128

Variables

This section is empty.

Functions

This section is empty.

Types

type KeepAlive

type KeepAlive int

KeepAlive is a pointer to the reference being kept alive.

func Acquire

func Acquire(reference any) KeepAlive

func (KeepAlive) Release

func (k KeepAlive) Release()

Jump to

Keyboard shortcuts

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