29 lines
414 B
Go
29 lines
414 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.company.lan/gopkg/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()
|
|
}
|