Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xxjwxc authored Sep 15, 2019
1 parent 5721b66 commit 9757d85
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 9757d85

Please sign in to comment.