| 255 | } |
| 256 | |
| 257 | func TestOverloadingASmallPool(t *testing.T) { |
| 258 | prePoolOpts := goleak.IgnoreCurrent() |
| 259 | |
| 260 | p := NewPool(&Config{ |
| 261 | MaxWorkers: 1, |
| 262 | QueueDepth: 11, |
| 263 | }) |
| 264 | opts := goleak.IgnoreCurrent() |
| 265 | |
| 266 | wg := &sync.WaitGroup{} |
| 267 | |
| 268 | for i := 0; i < 50; i++ { |
| 269 | wg.Add(1) |
| 270 | go func() { |
| 271 | fn := func(_ context.Context, _ interface{}) (interface{}, error) { |
| 272 | time.Sleep(time.Duration(rand.Uint32()%100) * time.Millisecond) |
| 273 | return nil, nil |
| 274 | } |
| 275 | payloads := []interface{}{1, 2} |
| 276 | _, _, _ = p.RunJobs(context.Background(), payloads, fn) |
| 277 | |
| 278 | wg.Done() |
| 279 | }() |
| 280 | } |
| 281 | |
| 282 | wg.Wait() |
| 283 | goleak.VerifyNone(t, opts) |
| 284 | |
| 285 | p.Shutdown() |
| 286 | goleak.VerifyNone(t, prePoolOpts) |
| 287 | } |
| 288 | |
| 289 | func TestShutdown(t *testing.T) { |
| 290 | prePoolOpts := goleak.IgnoreCurrent() |