mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-27 01:51:56 +08:00
Feat: archive & download routers for test
This commit is contained in:
21
pkg/task/pool.go
Normal file
21
pkg/task/pool.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package task
|
||||
|
||||
type Pool struct {
|
||||
// 容量
|
||||
capacity int
|
||||
// 终止信号
|
||||
terminateSignal chan error
|
||||
// 全部任务完成的信号
|
||||
finishSignal chan bool
|
||||
}
|
||||
|
||||
type Worker interface {
|
||||
Do() error
|
||||
}
|
||||
|
||||
func (pool *Pool) Submit(worker Worker) {
|
||||
err := worker.Do()
|
||||
if err != nil {
|
||||
close(pool.terminateSignal)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user