pool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: CC0-1.0 Imports: 5 Imported by: 0

Documentation

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 maintains a pool of elements available for reuse.

func New

func New(lifetime time.Duration, newFunc func() (interface{}, error), expiredFunc func(interface{})) *Pool

New returns a new pool, where items in the pool have the given lifetime. The function newFunc will be called to create a new item when the pool is empty; the function expiredFunc will be called when an item in the pool has expired, and may be nil.

func (*Pool) Close

func (p *Pool) Close() error

Close closes the pool, expiring any items currently in the pool and preventing new items from being created.

func (*Pool) Get

func (p *Pool) Get() (interface{}, error)

Get returns a new item from the pool.

func (*Pool) Put

func (p *Pool) Put(x interface{})

Put places the given item in the pool.

Jump to

Keyboard shortcuts

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