resourcePool

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnySlices = NewSlicePool[any](20)

AnySlices any切片池

View Source
var FieldSlices = NewSlicePool[fuzzTypes.Field](20)
View Source
var IntSlices = NewSlicePool[int](20)

IntSlices int切片池

View Source
var StringSlices = NewSlicePool[string](20)

StringSlices 字符串切片池

Functions

func GetReaction

func GetReaction() *fuzzTypes.Reaction

GetReaction 从池中获取一个新的Reaction结构

func GetReq

func GetReq() *fuzzTypes.Req

GetReq 从池中获取一个新的Req结构

func GetReqCtx

func GetReqCtx() *fuzzTypes.RequestCtx

GetReqCtx 从池中获取一个新的taskCtx结构

func PutReaction

func PutReaction(r *fuzzTypes.Reaction)

PutReaction 将用完的Reaction结构放回池

func PutReq

func PutReq(toPut *fuzzTypes.Req)

PutReq 放回用完的Req结构

func PutReqCtx

func PutReqCtx(toPut *fuzzTypes.RequestCtx)

PutReqCtx TaskCtx回池

Types

type SlicePool

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

SlicePool 通用切片对象池,支持任意类型切片[]T

func NewSlicePool

func NewSlicePool[T any](defCap int) *SlicePool[T]

NewSlicePool 创建新的切片对象池 defCap: 池为空时,新建切片的默认容量

func (*SlicePool[T]) Get

func (p *SlicePool[T]) Get(length int) []T

Get 从池中获取长度为length的切片 length < 0 时返回nil

func (*SlicePool[T]) Put

func (p *SlicePool[T]) Put(slice []T)

Put 将使用完毕的切片放回池中(截断为长度0以保留容量)

Jump to

Keyboard shortcuts

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