bufferpool

package module
v0.0.0-...-2deb6a8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: MIT Imports: 2 Imported by: 9 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

bufferpool

Very simple bytes.Buffer pool using sync.Pool.

Build Status

GoDoc

I got tired of writing the same sync.Pool for byte.Buffer objects.

SYNOPSIS

import "github.com/lestrrat-go/bufferpool"

var pool = bufferpool.New()

func main() {
    buf := pool.Get()
    defer pool.Release(buf)

    // ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() *bytes.Buffer

Get returns a bytes.Buffer from a global pool

func Release

func Release(buf *bytes.Buffer)

Release puts the given bytes.Buffer instance back in the global pool.

Types

type BufferPool

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

BufferPool is a sync.Pool for bytes.Buffer objects

func New

func New() *BufferPool

New creates a new BufferPool instance

func (*BufferPool) Get

func (bp *BufferPool) Get() *bytes.Buffer

Get returns a bytes.Buffer from the specified pool

func (*BufferPool) Release

func (bp *BufferPool) Release(buf *bytes.Buffer)

Release puts the given bytes.Buffer back in the specified pool after resetting it

Jump to

Keyboard shortcuts

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