MCPcopy Create free account
hub / github.com/dc0d/workerpool / ExampleWorkerPool_Expand

Function ExampleWorkerPool_Expand

workerpool_usage_test.go:175–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

173}
174
175func ExampleWorkerPool_Expand() {
176 pool := workerpool.New(-1, 0)
177 pool.Expand(1000, time.Millisecond, nil)
178
179 var v int64
180 go func() {
181 for i := 0; i < 100; i++ {
182 pool.Queue(func() {
183 atomic.AddInt64(&v, 1)
184 }, 0)
185 }
186 }()
187
188 pool.Stop()
189
190 if v != 100 {
191 panic("BOOM!")
192 }
193}
194
195//nolint
196func waitFunc(f func(), exitDelay time.Duration) error {

Callers

nothing calls this directly

Calls 3

ExpandMethod · 0.80
QueueMethod · 0.80
StopMethod · 0.80

Tested by

no test coverage detected