leakybuf

package
Version: v0.0.0-...-68ef78a Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Provides leaky buffer, based on the example in Effective Go.

Index

Constants

View Source
const (
	GlobalLeakyBufSize = 32 * 1024 // data.len(2) + hmacsha1(10) + data(4096)

)

Variables

View Source
var GlobalLeakyBuf = NewLeakyBuf(maxNBuf, GlobalLeakyBufSize)

Functions

This section is empty.

Types

type LeakyBuf

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

func NewLeakyBuf

func NewLeakyBuf(n, bufSize int) *LeakyBuf

NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each with bufSize bytes.

func (*LeakyBuf) Get

func (lb *LeakyBuf) Get() (b []byte)

Get returns a buffer from the leaky buffer or create a new buffer.

func (*LeakyBuf) Put

func (lb *LeakyBuf) Put(b []byte)

Put add the buffer into the free buffer pool for reuse. Panic if the buffer size is not the same with the leaky buffer's. This is intended to expose error usage of leaky buffer.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL