Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultDirtyFactor = 128
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool[T any] struct { // New is an optionally provided // allocator used when no value // is available for use in pool. New func() T // Reset is an optionally provided // value resetting function called // on passed value to Put(). Reset func(T) UnsafePool }
Pool provides a type-safe form of UnsafePool using generics.
Note it is NOT safe for concurrent use, you must protect it yourself!
type UnsafePool ¶
type UnsafePool struct { // DirtyFactor determines the max // number of $dirty count before // pool is garbage collected. Where: // $dirty = len(current) - len(victim) DirtyFactor int // contains filtered or unexported fields }
UnsafePool provides an incredibly simple memory pool implementation that stores ptrs to memory values, and regularly flushes internal pool structures according to DirtyFactor.
Note it is NOT safe for concurrent use, you must protect it yourself!
func (*UnsafePool) Get ¶
func (p *UnsafePool) Get() unsafe.Pointer
func (*UnsafePool) Put ¶
func (p *UnsafePool) Put(ptr unsafe.Pointer)
Click to show internal directories.
Click to hide internal directories.