done

package
v0.0.0-...-6d3478e Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosed        = errors.New("writer already closed")
	ErrLimitExceeded = errors.New("writer exceeded available space")
)

errors ...

Functions

This section is empty.

Types

type DoneFunc

type DoneFunc func(int, io.WriterTo) error

DoneFunc defines a function type for calling a close op.

type DonePool

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

DonePool exists to contain multiple RangePool that lies within giving distance range. It creates a internal array of DonePool which are distanced between each other by provided distance. Whenever giving call to get a bytes.Buffer for a giving size is within existing pool distances, it calls that RangePool responsible for that size and retrieves giving bytes.Buffer from that pool. If no range as such exists, it creates a new RangePool for the size + DonePool.Distance set an instantiation, then retrieves a bytes.Buffer from that.

func NewDonePool

func NewDonePool(distance int, initialAmount int) *DonePool

NewDonePool returns a new instance of a DonePool with size distance used for new pools and creates as many as the initialAmount of RangePools internally to service those size requests.

func (*DonePool) Get

func (bp *DonePool) Get(size int, doneFunc DoneFunc) io.WriteCloser

Get returns a new or existing bytes.Buffer from it's internal size RangePool. It gets a RangePool or creates one if non exists for the size + it's distance value then gets a bytes.Buffer from that RangePool.

func (*DonePool) Put

func (bp *DonePool) Put(bu *bytes.Buffer)

Put returns the bytes.Buffer by using the bu.Cap when greater than or equal to BytePool.distance, it either finds a suitable RangePool to keep this bytes.Buffer or else creates a new RangePool to cater for giving size.

Jump to

Keyboard shortcuts

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