pipool

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package pipool provides an extremely simple, non-thread-safe pool that can be used to reduce heap memory allocations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool is a very simple, non-thread-safe object pool.

It can only be used from a single goroutine. Since Pi runs on a single goroutine, it can safely be used in pi.Update and pi.Draw.

func (*Pool[T]) Get

func (p *Pool[T]) Get() *T

Get returns an object from the pool.

If the pool is empty, it creates a new zero-value object and returns a pointer to it.

func (*Pool[T]) Put

func (p *Pool[T]) Put(obj *T)

Put returns an object to the pool.

Jump to

Keyboard shortcuts

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