Files
pond/examples/dynamic_size/dynamic_size.go
T
2024-04-09 00:01:28 +03:00

26 lines
444 B
Go

package main
import (
"fmt"
"git.company.lan/gopkg/pond"
)
func main() {
// Create a buffered (non-blocking) pool that can scale up to 100 workers
// and has a buffer capacity of 1000 tasks
pool := pond.New(100, 1000)
// 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()
}