From 9757d85c818737b03d6aaef3f8106399369bc44b Mon Sep 17 00:00:00 2001 From: xiaojunxie <346944475@qq.com> Date: Sun, 15 Sep 2019 21:30:40 +0800 Subject: [PATCH] Update README.md --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 578f0d1..17bbf51 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,16 @@ ### 支持最大任务数, 放到工作池里面 并等待全部完成 ``` +package main + +import ( + "fmt" + "time" + + "github.com/xxjwxc/gowp/workerpool" +) + +func main() { wp := workerpool.New(10) //设置最大线程数 for i := 0; i < 20; i++ { //开启20个请求 ii := i @@ -24,10 +34,21 @@ wp.Wait() fmt.Println("down") +} ``` ### 支持错误返回 ``` +package main + +import ( + "fmt" + "time" + + "github.com/xxjwxc/gowp/workerpool" +) + +func main() { wp := workerpool.New(10) //设置最大线程数 for i := 0; i < 20; i++ { //开启20个请求 ii := i @@ -49,11 +70,22 @@ fmt.Println(err) } fmt.Println("down") + } ``` ### 支持判断是否完成 (非阻塞) ``` +package main + +import ( + "fmt" + "time" + + "github.com/xxjwxc/gowp/workerpool" +) + +func main() { wp := workerpool.New(5) //设置最大线程数 for i := 0; i < 10; i++ { //开启20个请求 // ii := i @@ -70,11 +102,22 @@ wp.Wait() fmt.Println(wp.IsDone()) fmt.Println("down") +} ``` ### 支持同步等待结果 ``` +package main + +import ( + "fmt" + "time" + + "github.com/xxjwxc/gowp/workerpool" +) + +func main() { wp := workerpool.New(5) //设置最大线程数 for i := 0; i < 10; i++ { //开启20个请求 ii := i @@ -98,5 +141,5 @@ fmt.Println(err) } fmt.Println("down") - -``` \ No newline at end of file +} +```