utils

package
v0.0.0-...-285da88 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TruncateDescriptiveNameLeft

func TruncateDescriptiveNameLeft(name string, max int, ellipsis string) (r string)

Types

type FinalizeWrapper

type FinalizeWrapper[T any] struct {
	// contains filtered or unexported fields
}

FinalizeWrapper Will run fin as finalizer when the wrapper object becomes unreachable _and_ is garbage collected. Note that using finalizers to manage resource heavy (e.g. memory regions) or scarce objects (e.g. file handles) is generally considered to be an anti-pattern (i.e. bad idea).

func NewFinalizeWrapper

func NewFinalizeWrapper[T any](obj T, fin func(obj T)) *FinalizeWrapper[T]

func (*FinalizeWrapper[T]) ForceFinalize

func (inst *FinalizeWrapper[T]) ForceFinalize()

func (*FinalizeWrapper[T]) Get

func (inst *FinalizeWrapper[T]) Get() (obj T)

Get May return a stale/invalidated obj if ForceFinalize() has been called before.

Jump to

Keyboard shortcuts

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