pool: bitbucket.org/oov/pool Index | Files

package pool

import "bitbucket.org/oov/pool"

Package pool provides map backed LRU pool.

Index

Package Files

pool.go

type Closabler Uses

type Closabler interface {
    Closable() bool
}

Closabler is the interface that wraps Closable method.

type CloseError Uses

type CloseError struct {
    Item interface{}
    Err  error
}

CloseError represents error on call Close().

func (CloseError) Error Uses

func (ce CloseError) Error() string

Error returns error message.

type Factory Uses

type Factory interface {
    New(key interface{}) (interface{}, error)
}

Factory is the interface of the pool factory.

type Pool Uses

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

Pool is the pool.

func New Uses

func New(f Factory) *Pool

New creates Pool.

func (*Pool) Close Uses

func (p *Pool) Close() error

Close disposes all items and finishes worker.

func (*Pool) Get Uses

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

Get gets item.

When an item does not exist, it creates via the Factroy.

func (*Pool) GetExists Uses

func (p *Pool) GetExists(key interface{}) (interface{}, bool)

GetExists gets item if it exists in pool.

func (*Pool) StartWorker Uses

func (p *Pool) StartWorker(deadline time.Duration, interval time.Duration) <-chan error

StartWorker runs worker goroutine.

func (*Pool) Sweep Uses

func (p *Pool) Sweep(deadline time.Duration, forceClose bool) error

Sweep closes unused item.

item does not close, when forceClose is false and item.Closable() is false.

Package pool imports 3 packages (graph). Updated 2016-12-22. Refresh now. Tools for package owners.