pool

package
v0.0.0-...-fe1b72b Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultBytesSlicePool    = NewBytesSlicePool(1024)
	DefaultBytesBufferPool   = NewBytesBufferPool()
	DefaultStringBuilderPool = NewStringBuilderPool()
)

Functions

func NewGoPool

func NewGoPool(maxNumber, minNumber int, idleTimeout time.Duration) *goPool

NewGoPool 新建一个协程池

func NewWorker

func NewWorker(id int, pool *goPool) *goWorker

NewWorker 新建一个工人

Types

type BytesBufferPool

type BytesBufferPool sync.Pool

BytesBufferPool 定义 *bytes.Buffer 复用池的类型

func NewBytesBufferPool

func NewBytesBufferPool() *BytesBufferPool

func (*BytesBufferPool) Alloc

func (own *BytesBufferPool) Alloc() *bytes.Buffer

Alloc 分配一个 *bytes.Buffer 对象

func (*BytesBufferPool) Dealloc

func (own *BytesBufferPool) Dealloc(obj *bytes.Buffer)

Dealloc 释放当前 *bytes.Buffer 对象

type BytesSlicePool

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

BytesSlicePool 定义 []byte 复用池的类型

func NewBytesSlicePool

func NewBytesSlicePool(sliceCap int, maxRecyclingCap ...int) *BytesSlicePool

NewBytesSlicePool 创建一个 []byte 复用池

func (*BytesSlicePool) Alloc

func (own *BytesSlicePool) Alloc() []byte

Alloc 分配一个 []byte 对象

func (*BytesSlicePool) Dealloc

func (own *BytesSlicePool) Dealloc(obj []byte)

Dealloc 释放当前 []byte 对象

type StringBuilderPool

type StringBuilderPool sync.Pool

StringBuilderPool 定义 *strings.Builder 复用池的类型

func NewStringBuilderPool

func NewStringBuilderPool() *StringBuilderPool

NewStringBuilderPool 创建一个 *strings.Builder 复用池

func (*StringBuilderPool) Alloc

func (own *StringBuilderPool) Alloc() *strings.Builder

Alloc 分配一个 *strings.Builder 对象

func (*StringBuilderPool) Dealloc

func (own *StringBuilderPool) Dealloc(obj *strings.Builder)

Dealloc 释放当前 *strings.Builder 对象

Jump to

Keyboard shortcuts

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