Documentation
¶
Overview ¶
Package pbuf is a lightweight pooled buffer.
Index ¶
- func CountItems() (outside int32, inside int32)
- func LimitInput(n int32)
- func LimitOutput(n int32)
- func SetNoPutBack(on bool)
- func SetSyncItem(on bool)
- type Buffer
- type BufferPool
- func (bufferPool BufferPool[USRDAT]) InvolveBuffer(buf *bytes.Buffer) *orbyte.Item[UserBuffer[USRDAT]]
- func (bufferPool BufferPool[USRDAT]) InvolveBytes(p ...byte) (b UserBytes[USRDAT])
- func (bufferPool BufferPool[USRDAT]) NewBuffer(buf []byte) *orbyte.Item[UserBuffer[USRDAT]]
- func (bufferPool BufferPool[USRDAT]) NewBytes(sz int) (b UserBytes[USRDAT])
- func (bufferPool BufferPool[USRDAT]) NewLargeBytes(sz int) (b UserBytes[USRDAT])
- func (bufferPool BufferPool[USRDAT]) ParseBuffer(buf *bytes.Buffer) *orbyte.Item[UserBuffer[USRDAT]]
- func (bufferPool BufferPool[USRDAT]) ParseBytes(p ...byte) (b UserBytes[USRDAT])
- type Bytes
- type OBuffer
- type Pool
- type UserBuffer
- type UserBytes
- func (b UserBytes[USRDAT]) B(f func([]byte, *USRDAT))
- func (b UserBytes[USRDAT]) Cap() (c int)
- func (b UserBytes[USRDAT]) Copy() (cb UserBytes[USRDAT])
- func (b UserBytes[USRDAT]) HasInit() bool
- func (b UserBytes[USRDAT]) Ignore() UserBytes[USRDAT]
- func (b UserBytes[USRDAT]) Len() int
- func (b UserBytes[USRDAT]) ManualDestroy()
- func (b UserBytes[USRDAT]) Slice(from, to int) UserBytes[USRDAT]
- func (b UserBytes[USRDAT]) SliceFrom(from int) UserBytes[USRDAT]
- func (b UserBytes[USRDAT]) SliceTo(to int) UserBytes[USRDAT]
- func (b UserBytes[USRDAT]) Trans() []byte
- func (b UserBytes[USRDAT]) V(f func([]byte))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
type Buffer = UserBuffer[struct{}]
type BufferPool ¶
type BufferPool[USRDAT any] struct { *orbyte.Pool[UserBuffer[USRDAT]] }
func NewBufferPool ¶
func NewBufferPool[USRDAT any]() BufferPool[USRDAT]
func (BufferPool[USRDAT]) InvolveBuffer ¶
func (bufferPool BufferPool[USRDAT]) InvolveBuffer( buf *bytes.Buffer, ) *orbyte.Item[UserBuffer[USRDAT]]
InvolveBuffer involve external *bytes.Buffer into Item.
func (BufferPool[USRDAT]) InvolveBytes ¶
func (bufferPool BufferPool[USRDAT]) InvolveBytes(p ...byte) (b UserBytes[USRDAT])
InvolveBytes involve outside buf into pool.
func (BufferPool[USRDAT]) NewBuffer ¶
func (bufferPool BufferPool[USRDAT]) NewBuffer( buf []byte, ) *orbyte.Item[UserBuffer[USRDAT]]
NewBuffer wraps bytes.NewBuffer into Item.
func (BufferPool[USRDAT]) NewBytes ¶
func (bufferPool BufferPool[USRDAT]) NewBytes(sz int) (b UserBytes[USRDAT])
NewBytes alloc sz bytes.
func (BufferPool[USRDAT]) NewLargeBytes ¶
func (bufferPool BufferPool[USRDAT]) NewLargeBytes(sz int) (b UserBytes[USRDAT])
NewLargeBytes alloc sz bytes without involving.
func (BufferPool[USRDAT]) ParseBuffer ¶
func (bufferPool BufferPool[USRDAT]) ParseBuffer( buf *bytes.Buffer, ) *orbyte.Item[UserBuffer[USRDAT]]
ParseBuffer convert external *bytes.Buffer into Item.
func (BufferPool[USRDAT]) ParseBytes ¶
func (bufferPool BufferPool[USRDAT]) ParseBytes(p ...byte) (b UserBytes[USRDAT])
ParseBytes convert outside bytes to Bytes safely without adding it into pool.
type Bytes ¶
type Bytes = UserBytes[struct{}]
func ParseBytes ¶
ParseBytes convert outside bytes to Bytes safely without adding it into pool.
type OBuffer ¶
func InvolveBuffer ¶
InvolveBuffer involve external *bytes.Buffer into Item.
func ParseBuffer ¶
ParseBuffer convert external *bytes.Buffer into Item.
type Pool ¶
type Pool = BufferPool[struct{}]
func GetDefaultBufferPool ¶
func GetDefaultBufferPool() Pool
GetDefaultBufferPool exposes inner bufferPool value.
type UserBuffer ¶
UserBuffer with customizable user data structure inside.
type UserBytes ¶
type UserBytes[USRDAT any] struct { // contains filtered or unexported fields }
UserBytes wrap pooled buffer into []byte while sharing the same pool.
func BufferItemToBytes ¶
func BufferItemToBytes[USRDAT any]( buf *orbyte.Item[UserBuffer[USRDAT]], ) (b UserBytes[USRDAT])
BufferItemToBytes convert between *Buffer and Bytes.
func (UserBytes[USRDAT]) ManualDestroy ¶
func (b UserBytes[USRDAT]) ManualDestroy()
ManualDestroy please refer to Item.ManualDestroy().