pool

package
v0.0.0-...-a855ea4 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pool manages a user defined set of resources.

Index

Constants

This section is empty.

Variables

View Source
var ErrPoolClosed = errors.New("Pool has been closed")

ErrPoolClosed is returned when an Acquire returns on a closed pool.

Functions

This section is empty.

Types

type Pool

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

Pool manages a set of resources that can be shared safely by multiple goroutines. The resource being managed must implement the io.Closer interface.

func New

func New(size uint, f func() (io.Closer, error)) (*Pool, error)

New creates a pool that manages resources. A pool requires a function that can allocate a new resource and the size of the pool.

func (*Pool) Acquire

func (p *Pool) Acquire() (io.Closer, error)

Acquire retrieves a resource from the pool.

func (*Pool) Close

func (p *Pool) Close() error

Close will shutdown the pool and close all existing resources.

func (*Pool) Release

func (p *Pool) Release(r io.Closer)

Release places a new resource onto the pool.

Directories

Path Synopsis
This sample program demonstrates how to use the pool package to share a simulated set of database connections.
This sample program demonstrates how to use the pool package to share a simulated set of database connections.

Jump to

Keyboard shortcuts

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