Documentation
¶
Overview ¶
Package bytepool provides a pool of []byte
Index ¶
- type Bytes
- func (b *Bytes) Close() error
- func (b *Bytes) Position(n uint)
- func (b *Bytes) ReadByte() (byte, error)
- func (b *Bytes) ReadFrom(r io.Reader) (n int64, err error)
- func (b *Bytes) ReadNFrom(n int64, r io.Reader) (m int64, err error)
- func (b *Bytes) ReadUint16() (uint16, error)
- func (b *Bytes) ReadUint32() (uint32, error)
- func (b *Bytes) ReadUint64() (uint64, error)
- func (b *Bytes) Release()
- func (b *Bytes) Reset()
- func (b *Bytes) SetOnExpand(callback func())
- func (b *Bytes) Write(data []byte) (n int, err error)
- func (b *Bytes) WriteByte(d byte) (err error)
- func (b *Bytes) WriteString(str string) (int, error)
- func (b *Bytes) WriteUint16(n uint16)
- func (b *Bytes) WriteUint32(n uint32)
- func (b *Bytes) WriteUint64(n uint64)
- type Pool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
func (*Bytes) ReadUint16 ¶
func (*Bytes) ReadUint32 ¶
func (*Bytes) ReadUint64 ¶
func (*Bytes) SetOnExpand ¶
func (b *Bytes) SetOnExpand(callback func())
Set a custom OnExpand callback (overwriting the one already set). Only useful for when NewBytes is called directly as opposed to through the pool.
func (*Bytes) WriteUint16 ¶
func (*Bytes) WriteUint32 ¶
func (*Bytes) WriteUint64 ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func New ¶
Create a new pool. The pool contains count items. Each item allocates an array of size bytes (but can dynamically grow)
func (*Pool) Depleted ¶
Get a count of how often Checkout() was called but no item was available (thus causing an item to be created on the fly) Calling this resets the counter
func (*Pool) Each ¶
Exposes every item currently in the pool If an item is checkout, each won't see it. As such, though thread-safe, you probably only want to call this method on init/startup.