pool

package module
v0.0.0-...-b334c81 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2017 License: MIT Imports: 0 Imported by: 2

README

pool - aah framework

Build Status codecov Go Report Card Version GoDoc License

v0.2 released and tagged on Mar 04, 2017

Generic interface{} pool in the form of bounded channel.

pool developed for aah framework. However, it's an independent library, can be used separately with any Go language project. Feel free to use it.

Installation

Stable - Version
# install the library
go get -u aahframework.org/pool.v0

See official page [TODO]

Documentation

Overview

Package pool provides channel based bounded pooling capabilities.

Index

Constants

View Source
const Version = "0.2"

Version no. of aah framework pool library

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {

	// New optionally specifies a function to generate
	// a value when Get would otherwise return nil.
	// It may not be changed concurrently with calls to Get.
	New func() interface{}
	// contains filtered or unexported fields
}

Pool holds the bounded channel for interface{}.

func NewPool

func NewPool(size int, fn func() interface{}) (p *Pool)

NewPool method creates a new Pool bounded to the given size.

func (*Pool) Count

func (p *Pool) Count() int

Count method returns current count of pool.

func (*Pool) Drain

func (p *Pool) Drain()

Drain method drains all the values for the channel

func (*Pool) Get

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

Get method gets a value from the Pool, or creates a new one if none are available in the pool.

func (*Pool) Put

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

Put method returns given value into Pool.

Jump to

Keyboard shortcuts

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