(t *testing.T)
| 586 | } |
| 587 | |
| 588 | func TestNonblockingSubmitWithFunc(t *testing.T) { |
| 589 | poolSize := 10 |
| 590 | ch := make(chan struct{}) |
| 591 | var wg sync.WaitGroup |
| 592 | p, err := ants.NewPoolWithFunc(poolSize, func(i any) { |
| 593 | longRunningPoolFunc(i) |
| 594 | wg.Done() |
| 595 | }, ants.WithNonblocking(true)) |
| 596 | require.NoError(t, err, "create TimingPool failed: %v", err) |
| 597 | defer p.Release() |
| 598 | wg.Add(poolSize) |
| 599 | for i := 0; i < poolSize-1; i++ { |
| 600 | require.NoError(t, p.Invoke(ch), "nonblocking submit when pool is not full shouldn't return error") |
| 601 | } |
| 602 | // p is full now. |
| 603 | require.NoError(t, p.Invoke(ch), "nonblocking submit when pool is not full shouldn't return error") |
| 604 | require.ErrorIsf(t, p.Invoke(nil), ants.ErrPoolOverload, |
| 605 | "nonblocking submit when pool is full should get an ants.ErrPoolOverload") |
| 606 | // interrupt f to get an available worker |
| 607 | close(ch) |
| 608 | wg.Wait() |
| 609 | wg.Add(1) |
| 610 | require.NoError(t, p.Invoke(ch), "nonblocking submit when pool is not full shouldn't return error") |
| 611 | wg.Wait() |
| 612 | } |
| 613 | |
| 614 | func TestNonblockingSubmitWithFuncGeneric(t *testing.T) { |
| 615 | poolSize := 10 |
nothing calls this directly
no test coverage detected
searching dependent graphs…