workerpool

package
v0.0.0-...-15b4a15 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

This package creates a very simple pool of goroutines. Sometimes a channel is not appropriate. There are probably more efficient ways of implementing this, but it is simple and works well.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

func New

func New(capacity uint) *Pool

New creates a new worker pool with the specified capacity

func (*Pool) Add

func (p *Pool) Add(count uint) uint

func (*Pool) Count

func (p *Pool) Count() uint

Count returns the current number of worker threads

func (*Pool) Done

func (p *Pool) Done()

Done is called by worker goroutines to signify they are quitting

func (*Pool) IsFull

func (p *Pool) IsFull() bool

IsFull returns true if the number of worker threads is greater than or equal to its capacity

func (*Pool) IsQuitting

func (p *Pool) IsQuitting() bool

func (*Pool) Quit

func (p *Pool) Quit()

func (*Pool) SetCapacity

func (p *Pool) SetCapacity(capacity uint)

SetCapacity adjusts the capacity of the Pool. If set lower than the current number of workers, calls to Add will return 0 until the number of workes becomes less than the capacity

func (*Pool) Wait

func (p *Pool) Wait()

Wait simply waits for all workers to exit

Jump to

Keyboard shortcuts

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