Skip to content

Commit

Permalink
fix: ci流程接入&&更新example
Browse files Browse the repository at this point in the history
  • Loading branch information
googs1025 committed May 31, 2023
1 parent f41f563 commit 2a82783
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestTaskPool1(t *testing.T) {

}
```

### 示例2
```go
/*
Expand Down
4 changes: 3 additions & 1 deletion pkg/workerpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ func (p *Pool) Run() {
p.wg.Wait()
}

// 把任务放入chan
// AddTask 把任务放入chan
func (p *Pool) AddTask(task *Task) {
// 放入chan
p.collector <- task
}

// RunBackground 后台运行,需要启动一个goroutine来执行
func (p *Pool) RunBackground() {
// 启动goroutine,打印。
go func() {
Expand All @@ -82,6 +83,7 @@ func (p *Pool) RunBackground() {

}

// StopBackground 停止后台运行,需要chan通知
func (p *Pool) StopBackground() {
klog.Info("pool close!")
for i := range p.Workers {
Expand Down

0 comments on commit 2a82783

Please sign in to comment.