-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
235 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### 示例: | ||
|
||
- example1_test.go:同步等待运行的协程池示例 | ||
- example2_test.go:异步等待运行的协程池示例 | ||
- scheduler包:简易型调度器 | ||
- http_example包:模拟httpServer暴露调度接口示例 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ func Execute() { | |
fmt.Printf("cmd err: %s\n", err) | ||
os.Exit(1) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package workerpool | ||
|
||
import "time" | ||
|
||
// Option 选项模式 | ||
type Option func(pool *Pool) | ||
|
||
// WithTimeout 设置超时时间 | ||
func WithTimeout(timeout time.Duration) Option { | ||
return func(p *Pool) { | ||
p.timeout = timeout | ||
} | ||
} | ||
|
||
// WithResultCallback 设置结果回调方法 | ||
func WithResultCallback(callback func(interface{})) Option { | ||
return func(p *Pool) { | ||
p.resultCallback = callback | ||
} | ||
} | ||
|
||
// WithErrorCallback 设置错误回调方法 | ||
func WithErrorCallback(callback func(error)) Option { | ||
return func(p *Pool) { | ||
p.errorCallback = callback | ||
} | ||
} |
Oops, something went wrong.