Documentation ¶
Overview ¶
Package recycle contains utilities for recyclable, concurrent read only memory usage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultChunkSizes = func() (sz []int) { for chSz := minDefChunkSize; chSz <= maxDefChunkSize; chSz *= 2 { sz = append(sz, chSz) } return }()
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data represents data which can have multiple concurrent readers and should been recycled in pool after Recycle call and when all concurrent reads are finished.
func (*Data) NewReader ¶
func (d *Data) NewReader() *DataReader
type DataReader ¶
type DataReader struct {
// contains filtered or unexported fields
}
func (*DataReader) Close ¶
func (r *DataReader) Close() error
type LeakCallback ¶
type LeakCallback func(*Data)
var PanicOnLeak LeakCallback = func(d *Data) { panic(fmt.Sprintf("recycle.Data leaked: %#v.", d)) }
var WarnOnLeak LeakCallback = func(d *Data) { println("WARN: recycle.Data leaked.") }
func NotifyOnLeak ¶
func NotifyOnLeak(leak chan<- *Data) LeakCallback
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func NewPoolSizes ¶
NewPoolSizes creates new pool, which produce chunks with sizes described in chunkSizes. chunkSizes should be sorted.
func (*Pool) MaxChunkSize ¶
func (*Pool) MinChunkSize ¶
func (*Pool) SetLeakCallback ¶
func (p *Pool) SetLeakCallback(cb LeakCallback)
SetLeakCallback sets callback, which is called before GC of not recycled data. Note: this is for test and debug purpose only.
Click to show internal directories.
Click to hide internal directories.