part

package
v0.28.20240417144109 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buf added in v0.21.1

type Buf[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](poolFunc PoolFunc[T], maxsize int) *Buf[T]

创建池

NewF: func() *T 新值

InUse func(*T) bool 是否在使用

ReuseF func(*T) *T 重用前处理

PoolF func(*T) *T 入池前处理

maxsize int 池最大数量

func (*Buf[T]) Get added in v0.21.1

func (t *Buf[T]) Get() *T

func (*Buf[T]) PoolState deprecated added in v0.28.1

func (t *Buf[T]) PoolState() (states []any)

states[] 0:pooled, 1:nopooled, 2:inuse, 3:nouse, 4:sum, 5:getPerSec

Deprecated: s

func (*Buf[T]) Put added in v0.21.1

func (t *Buf[T]) Put(item ...*T)

func (*Buf[T]) State added in v0.28.20240101145920

func (t *Buf[T]) State() BufState

type BufState added in v0.28.20240101145920

type BufState struct {
	Pooled, Nopooled, Inuse, Nouse, Sum int
	GetPerSec                           float64
}

type PoolFunc added in v0.28.20240125185017

type PoolFunc[T any] struct {
	// func() *T 新值
	New func() *T
	// func(*T) bool 是否在使用
	InUse func(*T) bool
	// func(*T) *T 重用(出池)前处理
	Reuse func(*T) *T
	// func(*T) *T 入池前处理
	Pool func(*T) *T
}

Jump to

Keyboard shortcuts

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