resource

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 7 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(obj any, token *Token)

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

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

func Untrack

func Untrack(obj any, token *Token)

Untrack stops tracking the lifetime of an object.

Types

type Token

type Token byte

Token should be a field of a tracked object.

The underlying type is not struct{} because (from the Go spec) "Two distinct zero-size variables may have the same address in memory", and they do.

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