pools

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2014 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pools provides a collection of pools which provide various data types with buffers. These can be used to lower the number of memory allocations and reuse buffers.

New pools should be added to this package to allow them to be shared across packages.

Utility functions which operate on pools should be added to this package to allow them to be reused.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Pool which returns bufio.Reader with a 32K buffer
	BufioReader32KPool *BufioReaderPool
	// Pool which returns bufio.Writer with a 32K buffer
	BufioWriter32KPool *BufioWriterPool
)

Functions

This section is empty.

Types

type BufioReaderPool

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

func (*BufioReaderPool) Get

func (bufPool *BufioReaderPool) Get(r io.Reader) *bufio.Reader

Get returns a bufio.Reader which reads from r. The buffer size is that of the pool.

func (*BufioReaderPool) NewReadCloserWrapper

func (bufPool *BufioReaderPool) NewReadCloserWrapper(buf *bufio.Reader, r io.Reader) io.ReadCloser

NewReadCloserWrapper returns a wrapper which puts the bufio.Reader back into the pool and closes the reader if it's an io.ReadCloser.

func (*BufioReaderPool) Put

func (bufPool *BufioReaderPool) Put(b *bufio.Reader)

Put puts the bufio.Reader back into the pool.

type BufioWriterPool

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

func (*BufioWriterPool) Get

func (bufPool *BufioWriterPool) Get(w io.Writer) *bufio.Writer

Get returns a bufio.Writer which writes to w. The buffer size is that of the pool.

func (*BufioWriterPool) NewWriteCloserWrapper

func (bufPool *BufioWriterPool) NewWriteCloserWrapper(buf *bufio.Writer, w io.Writer) io.WriteCloser

NewWriteCloserWrapper returns a wrapper which puts the bufio.Writer back into the pool and closes the writer if it's an io.Writecloser.

func (*BufioWriterPool) Put

func (bufPool *BufioWriterPool) Put(b *bufio.Writer)

Put puts the bufio.Writer back into the pool.

Jump to

Keyboard shortcuts

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