slicebytepool

package
v0.30.49 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 底层桶使用sync.Pool,内部的[]byte由sync.Pool决定何时释放
	StrategyMultiStdPoolBucket = iota + 1

	// 底层桶使用切片,内部的[]byte永远不会释放
	StrategyMultiSlicePoolBucket
)

Variables

This section is empty.

Functions

func Get

func Get(size int) []byte

func Init

func Init(strategy Strategy)

func Put

func Put(buf []byte)

Types

type Bucket

type Bucket interface {
	// 桶内无满足条件的[]byte时,返回nil
	Get(size int) []byte

	Put(buf []byte)
}

type ModSharedSliceByteOption

type ModSharedSliceByteOption func(option *SharedSliceByteOption)

type SharedSliceByte

type SharedSliceByte struct {
	Core []byte
	// contains filtered or unexported fields
}

func NewSharedSliceByte

func NewSharedSliceByte(size int, modOptions ...ModSharedSliceByteOption) *SharedSliceByte

func WrapSharedSliceByte

func WrapSharedSliceByte(b []byte, modOptions ...ModSharedSliceByteOption) *SharedSliceByte

func (*SharedSliceByte) Ref

func (ssb *SharedSliceByte) Ref() *SharedSliceByte

func (*SharedSliceByte) ReleaseIfNeeded

func (ssb *SharedSliceByte) ReleaseIfNeeded()

type SharedSliceByteOption

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

type SliceBucket

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

func NewSliceBucket

func NewSliceBucket() *SliceBucket

func (*SliceBucket) Get

func (b *SliceBucket) Get(size int) []byte

func (*SliceBucket) Put

func (b *SliceBucket) Put(buf []byte)

type SliceBytePool

type SliceBytePool interface {
	// 功能类似于 make([]byte, <size>)
	Get(size int) []byte

	Put(buf []byte)

	RetrieveStatus() Status
}

func NewSliceBytePool

func NewSliceBytePool(strategy Strategy) SliceBytePool

type Status

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

func RetrieveStatus

func RetrieveStatus() Status

type StdPoolBucket

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

func NewStdPoolBucket

func NewStdPoolBucket() *StdPoolBucket

func (*StdPoolBucket) Get

func (b *StdPoolBucket) Get(size int) []byte

func (*StdPoolBucket) Put

func (b *StdPoolBucket) Put(buf []byte)

type Strategy

type Strategy int

Jump to

Keyboard shortcuts

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