Bees
Bees - simple and lightweight worker pool for go.
Benchmarks:
10m tasks and 500k workers:
WorkerPool:
only 37MB used for 500k workers pool
Goroutines:
Semaphore:
Examples:
package main
import (
"context"
"fmt"
"github.com/peakle/bees"
)
// Example - demonstrate pool usage
func Example() {
pool := bees.Create(context.Background())
defer pool.Close()
t := 1
task := func(ctx context.Context) {
t++
fmt.Println(t)
}
pool.Submit(task)
pool.Submit(task)
pool.Submit(task)
pool.Wait()
// Output:
// 1
// 2
// 3
}