You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudreve/pkg/task/pool.go

22 lines
315 B

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)
}
}