Add ability to configure pool growth strategy
This commit is contained in:
@@ -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()
|
||||
}
|
||||
@@ -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 => ../../
|
||||
Reference in New Issue
Block a user