pool

package module
v0.0.0-...-3d2cc9c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2015 License: GPL-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LimitReached error = fmt.Errorf("limit reached")
View Source
var Timeout = fmt.Errorf("timeout")

Functions

This section is empty.

Types

type NewFunc

type NewFunc func() (interface{}, error)

type Pool

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

The Pool is the default/reference implementation of the pooler interface. It is safe for concurrent use. The New() function will never be called concurrently and so may access variables without worrying about concurrency protection

func NewPool

func NewPool(nf NewFunc) *Pool

NewPool takes a creator function and

func (*Pool) Get

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

Get will return an interface from the pool, or attempt to create a new one if it cannot get one. If the New() function is nil or returns an error, it will wait for an interface{} to become available via Put(). These will be processed with FIFO semantics.

func (*Pool) Put

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

func (*Pool) SetMax

func (p *Pool) SetMax(max uint)

func (*Pool) SetTimeout

func (p *Pool) SetTimeout(t time.Duration)

type Pooler

type Pooler interface {
	Get() (interface{}, error)
	Put(interface{})
}

Jump to

Keyboard shortcuts

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