Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/xxjwxc/gowp
Browse files Browse the repository at this point in the history
  • Loading branch information
谢小军 authored and 谢小军 committed Sep 15, 2019
2 parents 683acae + 9757d85 commit 194fb42
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -98,5 +141,5 @@
fmt.Println(err)
}
fmt.Println("down")
```
}
```

0 comments on commit 194fb42

Please sign in to comment.