pool

package
v0.2.2-0...-4624ec3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(parent context.Context, pool *Pool) context.Context

NewContext returns a Context whose Value method returns the worker pool.

Types

type Pool

type Pool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func FromContext

func FromContext(c context.Context) *Pool

FromContext returns the pool assigned to the context.

func New

func New() *Pool

func (*Pool) Allocate

func (p *Pool) Allocate(w worker.Worker) bool

Allocate allocates a worker to the pool to be available to accept work.

func (*Pool) Deallocate

func (p *Pool) Deallocate(w worker.Worker)

Deallocate removes the worker from the pool of available workers. If the worker is currently reserved and performing work it will finish, but no longer be given new work.

func (*Pool) IsAllocated

func (p *Pool) IsAllocated(w worker.Worker) bool

IsAllocated is a helper function that returns true if the worker is currently allocated to the Pool.

func (*Pool) List

func (p *Pool) List() []worker.Worker

List returns a list of all Workers currently allocated to the Pool.

func (*Pool) Release

func (p *Pool) Release(w worker.Worker) bool

Release releases the worker back to the pool of available workers.

func (*Pool) Reserve

func (p *Pool) Reserve() <-chan worker.Worker

Reserve reserves the next available worker to start doing work. Once work is complete, the worker should be released back to the pool.

Jump to

Keyboard shortcuts

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