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
+9
View File
@@ -0,0 +1,9 @@
module github.com/alitto/pond/examples/task_group
go 1.14
require (
github.com/alitto/pond v1.3.0
)
replace github.com/alitto/pond => ../../
+28
View File
@@ -0,0 +1,28 @@
package main
import (
"fmt"
"github.com/alitto/pond"
)
func main() {
// Create a pool
pool := pond.New(10, 1000)
defer pool.StopAndWait()
// Create a task group
group := pool.Group()
// Submit a group of related tasks
for i := 0; i < 20; i++ {
n := i
group.Submit(func() {
fmt.Printf("Running group task #%d\n", n)
})
}
// Wait for all tasks in the group to complete
group.Wait()
}