workerPool_test.go 350 B

12345678910111213141516171819202122232425
  1. package utl
  2. import (
  3. "os"
  4. "os/signal"
  5. "syscall"
  6. "testing"
  7. "time"
  8. )
  9. func TestWorkPool_Put(t *testing.T) {
  10. p := NewWorkPool(16)
  11. num := 100
  12. for num > 0 {
  13. p.Put(func(timer *time.Timer){
  14. time.Sleep(0 * time.Second)
  15. t.Log("in func")
  16. })
  17. num = num - 1
  18. }
  19. sig := make(chan os.Signal)
  20. signal.Notify(sig, syscall.SIGINT)
  21. t.Log(<-sig)
  22. }