workerPool_test.go 331 B

123456789101112131415161718192021
  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(NewJob(IJobFn(func(inf interface{}) error {
  11. time.Sleep(0 * time.Second)
  12. t.Log("num:", inf.(int))
  13. return nil
  14. }), num))
  15. num = num - 1
  16. }
  17. time.Sleep(time.Second)
  18. }