Documentation ¶
Overview ¶
Package bytepool implements a pool of bytes using a seg list.
Index ¶
Constants ¶
const DefaultPoolChanSize = uint32(32)
DefaultPoolChanSize is the default pool channel size.
Variables ¶
var DefaultListSizes = []uint32{
8,
16,
64,
256,
512,
1024,
4096,
8192,
16384,
32768,
65536,
131072,
262144,
524288,
1048576,
2097152,
4194304,
8388608,
16777216,
}
DefaultListSizes are the default list sizes.
Functions ¶
This section is empty.
Types ¶
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
Bytes represents a byte slice.
Only create these from SegLists.
func (*Bytes) CopyFrom ¶
CopyFrom copies from the byte slice to the Bytes starting at the offset.
Returns io.EOF if len(from) + offset is greater than the buffer size.
type ListStats ¶
type ListStats struct { // The list size. // 0 denotes no list. ListSize uint32 // Number of times New was called on the sync.Pool. TotalNew uint64 // Number of times Get was called on the *Pool. TotalGet uint64 // Number of outstanding messages that were not recycled. TotalUnrecycled uint64 }
ListStats are stats.
type SegList ¶
type SegList struct {
// contains filtered or unexported fields
}
SegList is a seg list.
Only create with NewSegList.
func NewNoPoolSegList ¶
func NewNoPoolSegList() *SegList
NewNoPoolSegList returns a new SegList that does no memory pooling.
func NewSegList ¶
func NewSegList(options ...SegListOption) *SegList
NewSegList returns a new SegList.
type SegListOption ¶
type SegListOption func(*SegList)
SegListOption is an option for a new SegList
func SegListWithListSizes ¶
func SegListWithListSizes(listSizes []uint32) SegListOption
SegListWithListSizes returns a SegListOption that uses the given list sizes.
The default is to use DefaultListSizes.
If listSizes is nil or empty, no lists will be used and all allocations will be done with make.
func SegListWithNoMemsetZero ¶
func SegListWithNoMemsetZero() SegListOption
SegListWithNoMemsetZero returns a SegListOption that does not clear allocated buffers.
Only do this if you know what you are doing.
func SegListWithPoolChanSize ¶
func SegListWithPoolChanSize(poolChanSize uint32) SegListOption
SegListWithPoolChanSize returns a SegListOption that uses the given pool channel size.
The default is to use DefaultPoolChanSize.
If poolChanSize is 0, no channel will be used and all allocations will be done with a sync.Pool.
Directories ¶
Path | Synopsis |
---|---|
Package bytepooltesting implements testing functionality for bytepool.
|
Package bytepooltesting implements testing functionality for bytepool. |