| 396 | } |
| 397 | |
| 398 | func TestPoolPanicWithoutHandler(t *testing.T) { |
| 399 | p0, err := ants.NewPool(10) |
| 400 | require.NoErrorf(t, err, "create new pool failed: %v", err) |
| 401 | defer p0.Release() |
| 402 | _ = p0.Submit(func() { |
| 403 | panic("Oops!") |
| 404 | }) |
| 405 | |
| 406 | p1, err := ants.NewPoolWithFunc(10, func(p any) { panic(p) }) |
| 407 | require.NoErrorf(t, err, "create new pool with func failed: %v", err) |
| 408 | defer p1.Release() |
| 409 | _ = p1.Invoke("Oops!") |
| 410 | |
| 411 | p2, err := ants.NewPoolWithFuncGeneric(10, func(p string) { panic(p) }) |
| 412 | require.NoErrorf(t, err, "create new pool with func failed: %v", err) |
| 413 | defer p2.Release() |
| 414 | _ = p2.Invoke("Oops!") |
| 415 | } |
| 416 | |
| 417 | func TestPoolPanicWithoutHandlerPreMalloc(t *testing.T) { |
| 418 | p0, err := ants.NewPool(10, ants.WithPreAlloc(true)) |