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