pool

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2015 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

README

pool

sync.Pool compatibility layer for for Go - falls back to a channel based pool in Go < 1.3

Please, use the following import path to ensure a stable API:

    import "gopkgs.com/pool.v1"

View other available versions, documentation and examples at http://gopkgs.com/pool

Documentation

Overview

Package pool provides a sync.Pool compatibility layer, which falls back to a channel based pool on Go < 1.3.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool sync.Pool

Pool is a thin compatibility type to allow Go libraries to use the new sync.Pool in Go 1.3, while remaining compatible with lower Go versions. For more information, see the sync.Pool type.

Example
p := pool.New(0)
p.Put("Hello")
fmt.Println(p.Get())
Output:

Hello

func New

func New(size int) *Pool

New returns a new Pool. The size argument is ignored on Go >= 1.3. In Go < 1.3, if size is zero, it's set to runtime.GOMAXPROCS(0) * 2.

func (*Pool) Get

func (p *Pool) Get() interface{}

Get returns an arbitrary previously Put value, removing it from the pool, or nil if there are no such values. Note that callers should not assume anything about the Get return value, since the runtime might decide to collect the elements from the pool at any time.

If there are no elements to return and the New() field is non-nil, Get returns the result of calling it.

func (*Pool) Put

func (p *Pool) Put(x interface{})

Put adds x to the pool.

Jump to

Keyboard shortcuts

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