pool

package
v2.10.18 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPoolClosed = errors.New("Pool has been closed")

Functions

This section is empty.

Types

type Pool

type Pool[T Poolable] struct {
	// contains filtered or unexported fields
}

func New

func New[T Poolable](fn func() (T, error), size uint) (*Pool[T], error)

New 函数工厂,指定有缓冲通道大小

func (*Pool[T]) Acquire

func (p *Pool[T]) Acquire() (T, error)

Acquire 池中获取资源

func (*Pool[T]) Close

func (p *Pool[T]) Close()

Close 池关闭所有现有资源

func (*Pool[T]) Release

func (p *Pool[T]) Release(r T)

Release 池中释放资源

type Poolable

type Poolable interface {
	Close() error
}

Jump to

Keyboard shortcuts

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