dockertest: github.com/ory/dockertest/docker/pkg/pools Index | Files

package pools

import "github.com/ory/dockertest/docker/pkg/pools"

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

Package Files

pools.go

Variables

var (
    // BufioReader32KPool is a pool which returns bufio.Reader with a 32K buffer.
    BufioReader32KPool = newBufioReaderPoolWithSize(buffer32K)
    // BufioWriter32KPool is a pool which returns bufio.Writer with a 32K buffer.
    BufioWriter32KPool = newBufioWriterPoolWithSize(buffer32K)
)

func Copy Uses

func Copy(dst io.Writer, src io.Reader) (written int64, err error)

Copy is a convenience wrapper which uses a buffer to avoid allocation in io.Copy.

type BufioReaderPool Uses

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

BufioReaderPool is a bufio reader that uses sync.Pool.

func (*BufioReaderPool) Get Uses

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 Uses

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 Uses

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

Put puts the bufio.Reader back into the pool.

type BufioWriterPool Uses

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

BufioWriterPool is a bufio writer that uses sync.Pool.

func (*BufioWriterPool) Get Uses

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 Uses

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 Uses

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

Put puts the bufio.Writer back into the pool.

Package pools imports 4 packages (graph) and is imported by 1 packages. Updated 2018-04-11. Refresh now. Tools for package owners.