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

Function ExampleWorkerPool

workerpool_usage_test.go:156–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154}
155
156func ExampleWorkerPool() {
157 pool := workerpool.New(-1, 0)
158
159 var v int64
160 go func() {
161 for i := 0; i < 100; i++ {
162 pool.Queue(func() {
163 atomic.AddInt64(&v, 1)
164 }, 0)
165 }
166 }()
167
168 pool.Stop()
169
170 if v != 100 {
171 panic("BOOM!")
172 }
173}
174
175func ExampleWorkerPool_Expand() {
176 pool := workerpool.New(-1, 0)

Callers

nothing calls this directly

Calls 2

QueueMethod · 0.80
StopMethod · 0.80

Tested by

no test coverage detected