bpool

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package bpool Provides bpool buffer pool

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer leaky buffer

func NewBuffer

func NewBuffer(maxFreeSize, capacity int) *Buffer

NewBuffer creates a leaky buffer which can hold at most n buffer, each with capacity bytes.

func (*Buffer) Get

func (sf *Buffer) Get() (b []byte)

Get returns a buffer from the leaky buffer or create a new buffer.

func (*Buffer) Put

func (sf *Buffer) Put(b []byte)

Put add the buffer into the free buffer pool for reuse. Panic if the buffer capacity is not the same with the leaky buffer's. This is intended to expose error usage of leaky buffer.

type BufferPool

type BufferPool interface {
	Get() []byte
	Put([]byte)
}

BufferPool buffer pool interface

type Pool

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

Pool pool buffer

func NewPool

func NewPool(capacity int) *Pool

NewPool creates a leaky buffer which can hold at most n buffer, each with capacity bytes.

func (*Pool) Get

func (sf *Pool) Get() []byte

Get selects an arbitrary item from the Pool, removes it from the Pool, and returns it to the caller.

func (*Pool) Put

func (sf *Pool) Put(b []byte)

Put adds x to the pool.

Jump to

Keyboard shortcuts

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