mpool

package
v0.0.0-...-077b43f Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Overview

Package mpool provides recycleable memory buffer to reduce gc.

Based upon slab class allocation algorithm.

Index

Constants

This section is empty.

Variables

View Source
var ErrorMessageOverflow = errors.New("message overflow")

Functions

func AccessLogLineBufferGet

func AccessLogLineBufferGet() []byte

func AccessLogLineBufferPut

func AccessLogLineBufferPut(b []byte)

func BytesBufferGet

func BytesBufferGet() *bytes.Buffer

func BytesBufferPut

func BytesBufferPut(b *bytes.Buffer)

Types

type Intern

type Intern struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewIntern

func NewIntern() *Intern

func (*Intern) String

func (this *Intern) String(s string) string

type Message

type Message struct {
	Body []byte
	// contains filtered or unexported fields
}

Message encapsulates the messages that we exchange back and forth.

func NewMessage

func NewMessage(size int) *Message

NewMessage is the supported way to obtain a new Message. This makes use of a "slab allocator" which greatly reduces the load on the garbage collector.

func (*Message) Free

func (this *Message) Free() (recycled bool)

Free decrements the reference count on a message, and releases its resources if no further references remain. While this is not strictly necessary thanks to GC, doing so allows for the resources to be recycled without engaging GC. This can have rather substantial benefits for performance.

Jump to

Keyboard shortcuts

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