resource

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package resource provides utilities for tracking resource lifetimes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Track

func Track[T any](obj *T, token *Token)

Track tracks the lifetime of an object until Untrack is called on it.

Obj should be a pointer to a struct with a field "token" of type *Token.

func Untrack

func Untrack[T any](obj *T, token *Token)

Untrack stops tracking the lifetime of an object.

It is safe to call this function multiple times concurrently.

Types

type Token

type Token struct {
	// contains filtered or unexported fields
}

Token is a field of a tracked object, holding the cleanup handle and a cleanup function with message.

func NewToken

func NewToken() *Token

NewToken returns a new Token.

Jump to

Keyboard shortcuts

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