keepalive

package
v0.9.0 Latest Latest
Warning

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

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

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