mempool

package
v2.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBuffer

func GetBuffer() *bytes.Buffer

GetBuffer takes a Buffer from the default buffer pool

func PutBuffer

func PutBuffer(x *bytes.Buffer)

PutBuffer returns Buffer to the default buffer pool

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is a Buffer pool.

func (*Buffer) Get

func (b *Buffer) Get() *bytes.Buffer

Get a Buffer from the pool.

func (*Buffer) Put

func (b *Buffer) Put(x *bytes.Buffer)

Put the Buffer back into pool. It resets the Buffer for reuse.

type BufferPool

type BufferPool interface {
	Get() *bytes.Buffer
	Put(x *bytes.Buffer)
}

func NewBuffer

func NewBuffer(max int) BufferPool

NewBuffer returns a buffer pool. The max specify the max capacity of the Buffer the pool will return. If the Buffer becoomes large than max, it will no longer be returned to the pool. If max <= 0, no limit will be enforced.

type BufferWithCap

type BufferWithCap struct {
	// contains filtered or unexported fields
}

BufferWithCap is a Buffer pool that

func (*BufferWithCap) Get

func (b *BufferWithCap) Get() *bytes.Buffer

Get a Buffer from the pool.

func (*BufferWithCap) Put

func (b *BufferWithCap) Put(x *bytes.Buffer)

Put the Buffer back into the pool if the capacity doesn't exceed the limit. It resets the Buffer for reuse.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL