freepool

package
v0.12.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package freepool manages a free pool of objects that are expensive to create.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool is a small pool of recently returned objects. Unlike sync.Pool, the pool is not subject to gargbage collection under memory pressure.

func New

func New(makeNew func() interface{}, clean func(v interface{})) *Pool

New returns a new free pool.

func (*Pool) Return

func (p *Pool) Return(v interface{})

Return returns an item to the pool after cleaning it.

func (*Pool) Take

func (p *Pool) Take() interface{}

Take returns an item from the pool, and if not available makes a new one.

Jump to

Keyboard shortcuts

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