resource

package
v0.0.0-...-bb56650 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT 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.

It is safe to call this function multiple times.

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