Add ability to configure pool growth strategy

This commit is contained in:
alitto
2020-05-22 21:03:43 -03:00
parent 349c5aa212
commit dc67fea72f
16 changed files with 671 additions and 207 deletions
+25
View File
@@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/alitto/pond"
)
func main() {
// Create an unbuffered (blocking) pool with a fixed
// number of workers
pool := pond.New(10, 0, pond.MinWorkers(10))
// Submit 1000 tasks
for i := 0; i < 1000; i++ {
n := i
pool.Submit(func() {
fmt.Printf("Running task #%d\n", n)
})
}
// Stop the pool and wait for all submitted tasks to complete
pool.StopAndWait()
}
+9
View File
@@ -0,0 +1,9 @@
module github.com/alitto/pond/examples/fixed_size
go 1.14
require (
github.com/alitto/pond v1.3.0
)
replace github.com/alitto/pond => ../../