pool

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewAllocError

func NewAllocError(target string) error

func WithLimit

func WithLimit(limit int64) option.AnyOption

Types

type AllocError

type AllocError struct {
	Target string
}

func (AllocError) Error

func (e AllocError) Error() string

type AtomicRef

type AtomicRef atomic.Int64

func (*AtomicRef) AddRef

func (r *AtomicRef) AddRef()

func (*AtomicRef) Release

func (r *AtomicRef) Release() bool

type Buffer

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

func NewBuffer

func NewBuffer(size uint, reversed uint) *Buffer

func (*Buffer) AddRef

func (b *Buffer) AddRef()

func (*Buffer) Alloc

func (b *Buffer) Alloc(size uint) *Data

func (*Buffer) Get

func (b *Buffer) Get() []byte

func (*Buffer) Release

func (b *Buffer) Release() bool

func (*Buffer) Remain

func (b *Buffer) Remain() uint

func (*Buffer) SetOnReleased

func (b *Buffer) SetOnReleased(onReleased func(*Buffer)) *Buffer

func (*Buffer) Size

func (b *Buffer) Size() uint

func (*Buffer) Unused

func (b *Buffer) Unused() []byte

func (*Buffer) Use

func (b *Buffer) Use() *Buffer

func (*Buffer) Used

func (b *Buffer) Used() []byte

type BufferPool

type BufferPool interface {
	Get() []byte

	Alloc(size uint) *Data
}

type Data

type Data struct {
	Data []byte
	Reference
	// contains filtered or unexported fields
}

func NewData

func NewData(data []byte) *Data

func (*Data) AddRef

func (d *Data) AddRef()

func (*Data) Cap

func (d *Data) Cap() uint

func (*Data) Compare

func (d *Data) Compare(o []byte) int

func (*Data) Contains

func (d *Data) Contains(sub []byte) bool

func (*Data) ContainsAny

func (d *Data) ContainsAny(chars string) bool

func (*Data) ContainsRune

func (d *Data) ContainsRune(r rune) bool

func (*Data) CopyFrom

func (d *Data) CopyFrom(off uint, b []byte) int

func (*Data) CopyStringFrom

func (d *Data) CopyStringFrom(off uint, s string) int

func (*Data) Count

func (d *Data) Count(sep []byte) int

func (*Data) Cut

func (d *Data) Cut(start uint, end uint) *Data

func (*Data) CutCap

func (d *Data) CutCap(start, end, cap uint) *Data

func (*Data) CutCapTo

func (d *Data) CutCapTo(end, cap uint) *Data

func (*Data) CutFrom

func (d *Data) CutFrom(start uint) *Data

func (*Data) CutTo

func (d *Data) CutTo(end uint) *Data

func (*Data) Equal

func (d *Data) Equal(o []byte) bool

func (*Data) Get

func (d *Data) Get(i uint) byte

func (*Data) HasPrefix

func (d *Data) HasPrefix(prefix []byte) bool

func (*Data) HasSuffix

func (d *Data) HasSuffix(suffix []byte) bool

func (*Data) IndexAny

func (d *Data) IndexAny(chars string) int

func (*Data) IndexByte

func (d *Data) IndexByte(c byte) int

func (*Data) IndexRune

func (d *Data) IndexRune(r rune) int

func (*Data) LastIndex

func (d *Data) LastIndex(sep []byte) int

func (*Data) LastIndexAny

func (d *Data) LastIndexAny(chars string) int

func (*Data) LastIndexByte

func (d *Data) LastIndexByte(c byte) int

func (*Data) Len

func (d *Data) Len() uint

func (*Data) LittleUint16

func (d *Data) LittleUint16(off uint) uint16

func (*Data) LittleUint32

func (d *Data) LittleUint32(off uint) uint32

func (*Data) LittleUint64

func (d *Data) LittleUint64(off uint) uint64

func (*Data) PutLittleUint16

func (d *Data) PutLittleUint16(off uint, v uint16) *Data

func (*Data) PutLittleUint32

func (d *Data) PutLittleUint32(off uint, v uint32) *Data

func (*Data) PutLittleUint64

func (d *Data) PutLittleUint64(off uint, v uint64) *Data

func (*Data) PutUint16

func (d *Data) PutUint16(off uint, v uint16) *Data

func (*Data) PutUint32

func (d *Data) PutUint32(off uint, v uint32) *Data

func (*Data) PutUint64

func (d *Data) PutUint64(off uint, v uint64) *Data

func (*Data) Release

func (d *Data) Release() bool

func (*Data) String

func (d *Data) String() string

func (*Data) Uint16

func (d *Data) Uint16(off uint) uint16

func (*Data) Uint32

func (d *Data) Uint32(off uint) uint32

func (*Data) Uint64

func (d *Data) Uint64(off uint) uint64

func (*Data) Use

func (d *Data) Use() *Data

type DataPool

type DataPool interface {
	Alloc(len uint) *Data

	AllocCap(len, cap uint) *Data
}

type DefaultBufferPool

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

func NewDefaultBufferPool

func NewDefaultBufferPool(size uint, reversed uint, poolProvider PoolProvider[*Buffer], poolOptions ...option.AnyOption) *DefaultBufferPool

func (*DefaultBufferPool) Alloc

func (p *DefaultBufferPool) Alloc(size uint) *Data

func (*DefaultBufferPool) Get

func (p *DefaultBufferPool) Get() []byte

type DynamicDataPool

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

func NewDynamicDataPool

func NewDynamicDataPool(pools ...*StaticDataPool) *DynamicDataPool

func NewDynamicDataPoolWithExp

func NewDynamicDataPoolWithExp(min, max uint, poolProvider PoolProvider[*Data], poolOptions ...option.AnyOption) *DynamicDataPool

func NewDynamicDataPoolWithThresholds

func NewDynamicDataPoolWithThresholds(thresholds []int, poolProvider PoolProvider[*Data], poolOptions ...option.AnyOption) *DynamicDataPool

func (*DynamicDataPool) Alloc

func (p *DynamicDataPool) Alloc(len uint) *Data

func (*DynamicDataPool) AllocCap

func (p *DynamicDataPool) AllocCap(len, cap uint) *Data

type InvalidReferenceError

type InvalidReferenceError struct {
	CurRef  int64
	LastRef int64
}

func NewInvalidReferenceError

func NewInvalidReferenceError(cur, last int64) InvalidReferenceError

func (InvalidReferenceError) Error

func (e InvalidReferenceError) Error() string

type Pool

type Pool[O any] interface {
	Get() O

	Put(obj O)
}

func ProvideSlicePool

func ProvideSlicePool[O any](new func(p Pool[O]) O, options ...option.AnyOption) Pool[O]

func ProvideSyncPool

func ProvideSyncPool[O any](new func(p Pool[O]) O, options ...option.AnyOption) Pool[O]

type PoolProvider

type PoolProvider[O any] func(new func(p Pool[O]) O, options ...option.AnyOption) Pool[O]

func StackPoolProvider

func StackPoolProvider[O any](size uint) PoolProvider[O]

type Reference

type Reference interface {
	Release() bool

	AddRef()
}

type Relations

type Relations struct {
	AtomicRef
	// contains filtered or unexported fields
}

func (*Relations) AddRelation

func (r *Relations) AddRelation(relation Reference)

func (*Relations) Clear

func (r *Relations) Clear()

func (*Relations) Release

func (r *Relations) Release() bool

type RelationsReference

type RelationsReference interface {
	Reference

	AddRelation(relation Reference)

	Clear()
}

type RingBufferPool

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

func NewRingBufferPool

func NewRingBufferPool(count uint, size uint, reversed uint) *RingBufferPool

func (*RingBufferPool) Alloc

func (p *RingBufferPool) Alloc(size uint) *Data

func (*RingBufferPool) Get

func (p *RingBufferPool) Get() []byte

type SlicePool

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

func NewSlicePool

func NewSlicePool[O any](new func(p *SlicePool[O]) O, options ...option.AnyOption) *SlicePool[O]

func (*SlicePool[O]) Cap

func (p *SlicePool[O]) Cap() int

func (*SlicePool[O]) Get

func (p *SlicePool[O]) Get() (o O)

func (*SlicePool[O]) Len

func (p *SlicePool[O]) Len() int

func (*SlicePool[O]) Put

func (p *SlicePool[O]) Put(obj O)

type StackPool

type StackPool[O any] struct {
	// contains filtered or unexported fields
}

func NewStackPool

func NewStackPool[O any](new func(p *StackPool[O]) O, size uint, options ...option.AnyOption) *StackPool[O]

func (*StackPool[O]) Cap

func (p *StackPool[O]) Cap() int

func (*StackPool[O]) Get

func (p *StackPool[O]) Get() (o O)

func (*StackPool[O]) Len

func (p *StackPool[O]) Len() int

func (*StackPool[O]) Put

func (p *StackPool[O]) Put(obj O)

type StaticDataPool

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

func NewStaticDataPool

func NewStaticDataPool(size uint, poolProvider PoolProvider[*Data], poolOptions ...option.AnyOption) *StaticDataPool

func (*StaticDataPool) Alloc

func (p *StaticDataPool) Alloc(len uint) (d *Data)

func (*StaticDataPool) AllocCap

func (p *StaticDataPool) AllocCap(len, cap uint) (d *Data)

func (*StaticDataPool) Size

func (p *StaticDataPool) Size() uint

type SwapPool

type SwapPool[O any] struct {
	// contains filtered or unexported fields
}

func NewSwapPool

func NewSwapPool[O any](cap int, creator func(p Pool[O]) O) *SwapPool[O]

func (*SwapPool[O]) Get

func (s *SwapPool[O]) Get() (o O)

func (*SwapPool[O]) Put

func (s *SwapPool[O]) Put(val O)

type SyncPool

type SyncPool[O any] struct {
	// contains filtered or unexported fields
}

func NewSyncPool

func NewSyncPool[O any](new func(p *SyncPool[O]) O, options ...option.AnyOption) *SyncPool[O]

func (*SyncPool[O]) Get

func (p *SyncPool[O]) Get() (o O)

func (*SyncPool[O]) Put

func (p *SyncPool[O]) Put(obj O)

Jump to

Keyboard shortcuts

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