tidb: github.com/pingcap/tidb/util/localpool Index | Files

package localpool

import "github.com/pingcap/tidb/util/localpool"

Index

Package Files

localpool.go localpool_norace.go

type LocalPool Uses

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

LocalPool is an thread local object pool. It's similar to sync.Pool but has some difference - It can define the size of the pool. - It never get GCed.

func NewLocalPool Uses

func NewLocalPool(sizePerProc int, newFn func() interface{}, resetFn func(obj interface{})) *LocalPool

NewLocalPool creates a pool. The sizePerProc is pool size for each PROC, so total pool size is (GOMAXPROCS * sizePerProc) It can only be used when the GOMAXPROCS never change after the pool created. newFn is the function to create a new object. resetFn is the function called before put back to the pool, it can be nil.

func (*LocalPool) Get Uses

func (p *LocalPool) Get() interface{}

Get gets an object from the pool.

func (*LocalPool) Put Uses

func (p *LocalPool) Put(obj interface{}) bool

Put puts an object back to the pool. It returns true if the pool is not full and the obj is successfully put into the pool.

Package localpool imports 2 packages (graph). Updated 2020-03-10. Refresh now. Tools for package owners.