objpool

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjPool

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

func NewObjPool

func NewObjPool(cfg PoolConfig) *ObjPool

func (*ObjPool) Drop

func (o *ObjPool) Drop()

Drop 丢弃一个

func (*ObjPool) Get

func (o *ObjPool) Get() interface{}

Get 获取对象,超过重试次数返回值为nil

func (*ObjPool) Lock

func (o *ObjPool) Lock()

Lock 用来外部锁定,在外部锁定状态下不要操作pool,否则会造成死锁

func (*ObjPool) Put

func (o *ObjPool) Put(v interface{})

Put 放回

func (*ObjPool) Reset

func (o *ObjPool) Reset()

Reset 清除所有

func (*ObjPool) Unlock

func (o *ObjPool) Unlock()

Unlock 解除锁定状态

type PoolConfig

type PoolConfig struct {
	Max           int           //obj最大个数
	Retry         int           //错误重试次数
	RetryInterval time.Duration //重试间隔
	ObjFactory    func() (interface{}, error)
}

Jump to

Keyboard shortcuts

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