()
| 173 | } |
| 174 | |
| 175 | func 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 |
| 196 | func waitFunc(f func(), exitDelay time.Duration) error { |