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 ¶
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 ¶
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.