utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2015 License: MIT Imports: 3 Imported by: 4

Documentation

Overview

Utilities used by falcore and its sub-packages

IMPORTANT: utils cannot import falcore or there will be a circular dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferPool

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

A leaky bucket buffer pool for bufio.Readers Dramatically reduces garbage when you have lots of short lived http connections.

func NewBufferPool

func NewBufferPool(poolSize, bufferSize int) *BufferPool

func (*BufferPool) Give

func (p *BufferPool) Give(bpe *BufferPoolEntry)

Return a buffer to the pool

func (*BufferPool) Take

func (p *BufferPool) Take(r io.Reader) (bpe *BufferPoolEntry)

Take a buffer from the pool and set it up to read from r

type BufferPoolEntry

type BufferPoolEntry struct {
	Br *bufio.Reader
	// contains filtered or unexported fields
}

This is what's stored in the buffer. It allows for the underlying io.Reader to be changed out inside a bufio.Reader. This is required for reuse.

func (*BufferPoolEntry) Read

func (bpe *BufferPoolEntry) Read(p []byte) (n int, err error)

make bufferPoolEntry a passthrough io.Reader

type WriteBufferPool

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

A leaky bucket buffer pool for bufio.Writers Dramatically reduces garbage when you have lots of short lived http connections.

func NewWriteBufferPool

func NewWriteBufferPool(poolSize, bufferSize int) *WriteBufferPool

func (*WriteBufferPool) Give

func (p *WriteBufferPool) Give(bpe *WriteBufferPoolEntry)

Return a buffer to the pool

func (*WriteBufferPool) Take

func (p *WriteBufferPool) Take(r io.Writer) (bpe *WriteBufferPoolEntry)

Take a buffer from the pool and set it up to read from r

type WriteBufferPoolEntry

type WriteBufferPoolEntry struct {
	Br *bufio.Writer
	// contains filtered or unexported fields
}

This is what's stored in the buffer. It allows for the underlying io.Writer to be changed out inside a bufio.Writer. This is required for reuse.

func (*WriteBufferPoolEntry) Write

func (bpe *WriteBufferPoolEntry) Write(p []byte) (n int, err error)

make bufferPoolEntry a passthrough io.Writer

Jump to

Keyboard shortcuts

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