This commit is contained in:
邹宗楠
2023-05-29 16:46:26 +08:00
parent 9fee44b6fd
commit 958ab4686d
3 changed files with 120 additions and 60 deletions

View File

@@ -8,6 +8,7 @@ import (
"strconv"
"strings"
"testing"
"time"
"unicode/utf8"
)
@@ -82,3 +83,19 @@ func TestTen216(t *testing.T) {
fmt.Println(gg)
fmt.Println(kk)
}
func TestSimplePool(t *testing.T) {
p := NewSimplePoll(20)
for i := 0; i < 100; i++ {
p.Add(parseTask(i))
}
p.Run()
}
func parseTask(i int) func() {
return func() {
// 模拟抓取数据的过程
time.Sleep(time.Second * 1)
fmt.Println("finish parse ", i)
}
}