pool

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GzipWriterPool = &sync.Pool{
		New: func() interface{} {
			gw, err := gzip.NewWriterLevel(nil, defaultGzipContentEncodingLevel)
			if err != nil {
				panic(err)
			}
			return gw
		},
	}

	GzipReaderPool = &sync.Pool{
		New: func() interface{} {
			gw := GzipWriterPool.Get().(*gzip.Writer)
			defer GzipWriterPool.Put(gw)
			b := new(bytes.Buffer)
			gw.Reset(b)
			gw.Flush()
			gw.Close()
			gr, err := gzip.NewReader(bytes.NewReader(b.Bytes()))
			if err != nil {
				panic(err.Error())
			}
			return gr
		},
	}
)
View Source
var (
	BytesPool = &bytesPool{pool: make(chan []byte, 1000), baseWidth: 32 * 1024} // 32KB
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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