Lindenii Project Forge
Login

go-lindenii-common

Common library for the Lindenii Project

Warning: Due to various recent migrations, viewing non-HEAD refs may be broken.

/gpool/pool.go (raw)

package gpool

import "sync"

type Pool[T any] struct {
	p   sync.Pool
	New func() T
}

func (p *Pool[T]) Get() T {
	return p.p.Get().(T)
}

func (p *Pool[T]) Put(x T) {
	p.p.Put(x)
}