pool

package
v0.0.0-...-8dc309f Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool[T any] struct {
	New func() T
	// contains filtered or unexported fields
}

包装 sync.Pool

func (*Pool[T]) Get

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

func (*Pool[T]) Put

func (p *Pool[T]) Put(x T)

type PoolChan

type PoolChan[T any] struct {
	New func() T
	// contains filtered or unexported fields
}

由chan实现的池 避免 sync.Pool GC 回收问题

func NewPoolCap

func NewPoolCap[T any](maxSize int, new func() T) (bp *PoolChan[T])

func (*PoolChan[T]) Cap

func (p *PoolChan[T]) Cap() int

func (*PoolChan[T]) Get

func (p *PoolChan[T]) Get() (b T)

func (*PoolChan[T]) Len

func (p *PoolChan[T]) Len() int

func (*PoolChan[T]) Put

func (p *PoolChan[T]) Put(b T)

放回池,等待复用

Jump to

Keyboard shortcuts

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