workerPool_test.go 264 B

12345678910111213141516171819
  1. package utl
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestWorkPool_Put(t *testing.T) {
  7. p := NewWorkPool(WithWorkPoolSize(16))
  8. num := 2
  9. for num > 0 {
  10. p.Put(func(timer *time.Timer) {
  11. time.Sleep(0 * time.Second)
  12. })
  13. num = num - 1
  14. }
  15. time.Sleep(time.Second)
  16. }