falcore: github.com/fitstar/falcore/utils Index | Files

package utils

import "github.com/fitstar/falcore/utils"

Utilities used by falcore and its sub-packages

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

Index

Package Files

buffer_pool.go doc.go write_buffer_pool.go

type BufferPool Uses

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 Uses

func NewBufferPool(poolSize, bufferSize int) *BufferPool

func (*BufferPool) Give Uses

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

Return a buffer to the pool

func (*BufferPool) Take Uses

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 Uses

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 Uses

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

make bufferPoolEntry a passthrough io.Reader

type WriteBufferPool Uses

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 Uses

func NewWriteBufferPool(poolSize, bufferSize int) *WriteBufferPool

func (*WriteBufferPool) Give Uses

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

Return a buffer to the pool

func (*WriteBufferPool) Take Uses

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 Uses

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 Uses

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

make bufferPoolEntry a passthrough io.Writer

Package utils imports 3 packages (graph) and is imported by 2 packages. Updated 2016-07-16. Refresh now. Tools for package owners.