sync

package
v5.0.0-...-2e5c9d0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBufioReader

func GetBufioReader(reader io.Reader) *bufio.Reader

GetBufioReader returns a *bufio.Reader that is managed by a sync.Pool. Returns a bufio.Reader that is resetted with reader and ready for use.

After use, the *bufio.Reader should be put back into the sync.Pool by calling PutBufioReader.

func GetByteSlice

func GetByteSlice() *[]byte

GetByteSlice returns a *[]byte that is managed by a sync.Pool. The initial slice length will be 16384 (16kb).

After use, the *[]byte should be put back into the sync.Pool by calling PutByteSlice.

func GetBytesBuffer

func GetBytesBuffer() *bytes.Buffer

GetBytesBuffer returns a *bytes.Buffer that is managed by a sync.Pool. Returns a buffer that is resetted and ready for use.

After use, the *bytes.Buffer should be put back into the sync.Pool by calling PutBytesBuffer.

func GetZlibWriter

func GetZlibWriter(w io.Writer) *zlib.Writer

GetZlibWriter returns a *zlib.Writer that is managed by a sync.Pool. Returns a writer that is resetted with w and ready for use.

After use, the *zlib.Writer should be put back into the sync.Pool by calling PutZlibWriter.

func PutBufioReader

func PutBufioReader(reader *bufio.Reader)

PutBufioReader puts reader back into its sync.Pool.

func PutByteSlice

func PutByteSlice(buf *[]byte)

PutByteSlice puts buf back into its sync.Pool.

func PutBytesBuffer

func PutBytesBuffer(buf *bytes.Buffer)

PutBytesBuffer puts buf back into its sync.Pool.

func PutZlibReader

func PutZlibReader(z ZLibReader)

PutZlibReader puts z back into its sync.Pool, first closing the reader. The Byte slice dictionary is also put back into its sync.Pool.

func PutZlibWriter

func PutZlibWriter(w *zlib.Writer)

PutZlibWriter puts w back into its sync.Pool.

Types

type ZLibReader

type ZLibReader struct {
	Reader zlibReadCloser
	// contains filtered or unexported fields
}

func GetZlibReader

func GetZlibReader(r io.Reader) (ZLibReader, error)

GetZlibReader returns a ZLibReader that is managed by a sync.Pool. Returns a ZLibReader that is resetted using a dictionary that is also managed by a sync.Pool.

After use, the ZLibReader should be put back into the sync.Pool by calling PutZlibReader.

Jump to

Keyboard shortcuts

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