pool

package module
v0.0.0-...-d102a2c Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2014 License: MIT Imports: 4 Imported by: 1

README

go-pool

Go sync.Pool applications

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeflatePool

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

DeflatePool manages a pool of flate.Writer flate.NewWriter allocates a lot of memory, so if flate.Writer are needed frequently, it's more efficient to use a pool of them. The pool uses sync.Pool internally.

There is no pool for flate readers, because they implement io.ReadCloser and can't be recycled after closing.

var Deflate DeflatePool

func (*DeflatePool) GetWriter

func (pool *DeflatePool) GetWriter(dst io.Writer) (writer *flate.Writer)

GetWriter returns flate.Writer from the pool, or creates a new one with flate.BestCompression if the pool is empty.

func (*DeflatePool) PutWriter

func (pool *DeflatePool) PutWriter(writer *flate.Writer)

PutWriter returns a flate.Writer to the pool that can late be reused via GetWriter. Don't close the writer, Flush will be called before returning it to the pool.

type GzipPool

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

GzipPool manages a pool of gzip.Writer. The pool uses sync.Pool internally.

var Gzip GzipPool

func (*GzipPool) GetReader

func (pool *GzipPool) GetReader(src io.Reader) (reader *gzip.Reader)

GetReader returns gzip.Reader from the pool, or creates a new one if the pool is empty.

func (*GzipPool) GetWriter

func (pool *GzipPool) GetWriter(dst io.Writer) (writer *gzip.Writer)

GetWriter returns gzip.Writer from the pool, or creates a new one with gzip.BestCompression if the pool is empty.

func (*GzipPool) PutReader

func (pool *GzipPool) PutReader(reader *gzip.Reader)

PutReader closes and returns a gzip.Reader to the pool so that it can be reused via GetReader.

func (*GzipPool) PutWriter

func (pool *GzipPool) PutWriter(writer *gzip.Writer)

PutWriter closes and returns a gzip.Writer to the pool so that it can be reused via GetWriter.

Jump to

Keyboard shortcuts

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