gpool_test.go 347 B

123456789101112131415161718192021
  1. package common
  2. import (
  3. "fmt"
  4. "sync"
  5. "testing"
  6. "time"
  7. )
  8. func Test_gPool_AddJob(t *testing.T) {
  9. pool := New(10, true)
  10. result := sync.Map{}
  11. for x := 0; x < 1000; x++ {
  12. pool.AddJob(func(args ...interface{}) {
  13. result.Store(args[0],nil)
  14. fmt.Println("run: ", args)
  15. time.Sleep(time.Second)
  16. }, x)
  17. }
  18. time.Sleep(time.Second * 100)
  19. }