Documentation
¶
Index ¶
- Variables
- func Alloc(size int) []byte
- func AllocCap(size, capacity int) []byte
- func AllocZeroed(size int) []byte
- func AllocZeroedCap(size, capacity int) []byte
- func Free(b []byte)
- type AllocFunc
- type ByteSlices
- type CircleBuf
- type Config
- type DeInitFunc
- type DeallocFunc
- type InitFunc
- type Pool
- type RC
- type Shard
- type ShardStats
- type SizeClass
- type SizeClasses
- type Slices
- type SlicesSlab
- type Stats
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNeedAllocFunc = errors.New("need alloc func")
)
Functions ¶
func AllocZeroed ¶
func AllocZeroedCap ¶
Types ¶
type ByteSlices ¶
type ByteSlices struct {
// contains filtered or unexported fields
}
func DefaultBytes ¶
func DefaultBytes() *ByteSlices
func NewByteSlices ¶
func NewByteSlices(sizes *SizeClasses) *ByteSlices
func (*ByteSlices) Alloc ¶
func (b *ByteSlices) Alloc(size int) []byte
func (*ByteSlices) AllocCap ¶
func (b *ByteSlices) AllocCap(size, capacity int) []byte
func (*ByteSlices) AllocZeroed ¶
func (b *ByteSlices) AllocZeroed(size int) []byte
func (*ByteSlices) AllocZeroedCap ¶
func (b *ByteSlices) AllocZeroedCap(size, capacity int) []byte
func (*ByteSlices) Free ¶
func (b *ByteSlices) Free(data []byte)
type CircleBuf ¶
type CircleBuf struct {
// contains filtered or unexported fields
}
func NewCircleBuf ¶
func (*CircleBuf) DequeueUnsafe ¶
type Config ¶
type Config[T any] struct { SizeClass, NumShards int PageSize, PagesPerShard int64 AllocFunc[T] DeallocFunc[T] InitFunc[T] DeInitFunc[T] }
type DeInitFunc ¶
type DeallocFunc ¶
type Shard ¶
type Shard[T any] struct { ShardStats // contains filtered or unexported fields }
type ShardStats ¶
type SizeClasses ¶
type SizeClasses struct {
Size8 SizeClass
Size16 SizeClass
Size32 SizeClass
Size64 SizeClass
Size128 SizeClass
Size256 SizeClass
Size512 SizeClass
Size1K SizeClass
Size2K SizeClass
Size4K SizeClass
Size8K SizeClass
Size16K SizeClass
Size32K SizeClass
Size64K SizeClass
Size128K SizeClass
Size256K SizeClass
Size512K SizeClass
Size1M SizeClass
Size2M SizeClass
Size4M SizeClass
Size8M SizeClass
Size16M SizeClass
Size32M SizeClass
Size64M SizeClass
Size128M SizeClass
Size256M SizeClass
Size512M SizeClass
Size1G SizeClass
}
SizeClasses are power of 2 up to 1G Pool is unlikely the ideal choice for sizes larger than 8kb. Best use cases are a lot of smallish allocations and frees with high contention.
func DefaultSizeClasses ¶
func DefaultSizeClasses() *SizeClasses
type Slices ¶
type Slices[T any] struct { // contains filtered or unexported fields }
func (*Slices[T]) Slab ¶
func (s *Slices[T]) Slab(size int) SlicesSlab[T]
type SlicesSlab ¶
type SlicesSlab[T any] struct { // contains filtered or unexported fields }
func (SlicesSlab[T]) Get ¶
func (s SlicesSlab[T]) Get() []T
func (SlicesSlab[T]) Put ¶
func (s SlicesSlab[T]) Put(data []T)
func (SlicesSlab[T]) PutZeroed ¶
func (s SlicesSlab[T]) PutZeroed(data []T)
Click to show internal directories.
Click to hide internal directories.