Skip to content

charlesgregory/workerpool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

This is a simple worker pool package for go.

To install:

go get github.com/charlesgregory/workerpool

Example of how to use:

type work struct{
	a,b,res int
}
func doWork(payload interface{})interface{}{
	var task=payload.(work)
	task.res=task.a+task.b
	return task
}
func TestSimple(t *testing.T){
	p:=NewPool(4)
	p.Start()
	for i:=0;i<100000;i++{
		p.NewTask(doWork,work{a:i,b:i+1})
	}
	p.Close()
	for task:=range p.RetChan.Recv{
		w:=task.(work)
		if !(w.a+w.b==w.res){
			t.Fail()
		}
	}
}

About

A simple go worker pool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages