/gopool

A simple goroutine pool

Primary LanguageGo

A simple goroutine pool

Usage

lazy load pool

p := NewPoolLazyWorker(1024)
p.Schedule(func() {
    fmt.Println("hello go pool")
})
time.Sleep(time.Second * 2)
fmt.Println("done")

hungry load pool

p := NewPoolHungryWorker(1024, 512)
p.Schedule(func() {
    fmt.Println("hello go pool")
})
time.Sleep(time.Second * 2)
fmt.Println("done")

pool with timeout

p := NewPoolLazyWorker(1024)
p.Schedule(func() {
    fmt.Println("hello go pool")
}, time.Second * 1)
time.Sleep(time.Second * 2)
fmt.Println("done")