Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Destroyable ¶
type Destroyable interface {
Destroy()
}
Object implementing Destroyable added to a Map will have their Destroy() method called when the object is about to be removed. This replaces use of a finalizer.
type Map ¶
type Map[K comparable, T any] struct { // contains filtered or unexported fields }
Map is a thread safe map for objects to be kept as weak references, useful for cache/etc
func (*Map[K, T]) Delete ¶
func (w *Map[K, T]) Delete(k K)
Delete removes element at key k from the map. This doesn't call Destroy immediately as this would typically happen when the object is actually cleared by the garbage collector and instances of said object may still be used.
type Ref ¶
type Ref[T any] struct { // contains filtered or unexported fields }
Ref is a weak reference to a Go object
func NewRef ¶
NewRef returns a reference to the object v that may be cleared by the garbage collector
func NewRefDestroyer ¶
NewRefDestroyer returns a reference to the object v that may be cleared by the garbage collector, in which case destroy will be called.