Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBytesCapacityTooSmall = errors.New("bytes capacity is too small")
var ErrPoolFull = errors.New("pool is full")
var ErrPoolTooSmall = errors.New("pool is too small")
Functions ¶
This section is empty.
Types ¶
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
type BytesPool ¶
type BytesPool struct {
// contains filtered or unexported fields
}
BytesPool is a pool of Bytes
func NewBytesPool ¶
NewBytesPool create a new BytesPool maxMemory is the threshold value (in byte) of memory the BytesPool could increase, eg. 1024 * 1024 * 1024 (1G) if maxMemory == 0, the capacity of the pool is unLimited segmentSize (byte) is the size of the segment, eg. 1024 * 4, maxMeory / segmentSize is the capacity of the pool which means the max number of the segments in the pool
func (*BytesPool) NewBytes ¶
NewBytes create a new Bytes something like []byte length is the max length of the Bytes (in byte) eg, 1024 * 1024 (1M) data in Bytes is a list of []byte, the size of []byte is pool's segmentSize, like 4k so, the max length of the Bytes is bl / segmentSize if length == 0, it is not limited, it may use all of the bytes in the pool