memorypool

package module
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 6 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

linearpool

Documentation

Index

Constants

View Source
const (
	DiKB int64 = 1 << 10
	DiMB int64 = DiKB << 10
	DiGB int64 = DiMB << 10
)

Variables

View Source
var (
	SliceExtendRatio        = 2.5
	BugfixClearPointerInMem = true
	BugfixCorruptOtherMem   = true
)

Functions

func Append

func Append[T any](ac *Allocator, s []T, elem T) []T

Append append slice

func AppendInbound added in v0.4.0

func AppendInbound[T any](ac *Allocator, s []T, elem T) []T

AppendInbound 确定范围内 append

func AppendInplace added in v0.3.0

func AppendInplace[T any](ac *Allocator, s []T, elem T) []T

AppendInplace 与 NewSlice 之间没有任何新的内存分配时使用

func AppendInplaceMulti added in v0.3.0

func AppendInplaceMulti[T any](ac *Allocator, s []T, elems ...T) []T

AppendInplaceMulti 与 NewSlice 之间没有任何新的内存分配时使用

func AppendMulti added in v0.3.0

func AppendMulti[T any](ac *Allocator, s []T, elems ...T) []T

AppendMulti append slice

func New

func New[T any](ac *Allocator) (r *T)

New 分配新对象

func NewSlice

func NewSlice[T any](ac *Allocator, len, cap int) (r []T)

NewSlice does not zero the slice automatically, this is OK with most cases and can improve the performance. zero it yourself for your need.

Types

type Allocator

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

Allocator 分配器

func NewAlloctorFromPool

func NewAlloctorFromPool(bsize int64) *Allocator

NewAlloctorFromPool 新建分配池, blocksize >= bsize

func (*Allocator) AddSubAlloctor added in v0.5.1

func (ac *Allocator) AddSubAlloctor(sub *Allocator)

AddSubAlloctor 新增子分配器

func (*Allocator) BlockSize added in v0.2.0

func (ac *Allocator) BlockSize() int64

BlockSize 获取当前内存池的 blocksize

func (*Allocator) Bool

func (ac *Allocator) Bool(v bool) (r *bool)

Bool ...

func (*Allocator) Debug

func (ac *Allocator) Debug()

Debug 输出 debug 信息

func (*Allocator) Float32

func (ac *Allocator) Float32(v float32) (r *float32)

Float32 ...

func (*Allocator) Float64

func (ac *Allocator) Float64(v float64) (r *float64)

Float64 ...

func (*Allocator) Int

func (ac *Allocator) Int(v int) (r *int)

Int ...

func (*Allocator) Int32

func (ac *Allocator) Int32(v int32) (r *int32)

Int32 ...

func (*Allocator) Int64

func (ac *Allocator) Int64(v int64) (r *int64)

Int64 ...

func (*Allocator) KeepAlive added in v0.3.0

func (ac *Allocator) KeepAlive(ptr interface{})

KeepAlive GC保活

func (*Allocator) Merge added in v0.2.0

func (ac *Allocator) Merge(src *Allocator) *Allocator

Merge 合并其他内存池

func (*Allocator) NewString

func (ac *Allocator) NewString(v string) string

NewString 从内存池分配 string

func (*Allocator) Reset

func (ac *Allocator) Reset()

Reset 重置内存信息

func (*Allocator) ReturnAlloctorToPool

func (ac *Allocator) ReturnAlloctorToPool()

ReturnAlloctorToPool 归还分配池

func (*Allocator) String

func (ac *Allocator) String(v string) (r *string)

String ...

func (*Allocator) SubAlloctor added in v0.5.1

func (ac *Allocator) SubAlloctor() []*Allocator

SubAlloctor 获取子分配器

func (*Allocator) Uint32

func (ac *Allocator) Uint32(v uint32) (r *uint32)

Uint32 ...

func (*Allocator) Uint64

func (ac *Allocator) Uint64(v uint64) (r *uint64)

Uint64 ...

type Logger

type Logger interface {
	Errorf(format string, args ...interface{})
}

Jump to

Keyboard shortcuts

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