并发模型,runner
runner
模型概述
runner模型做的事情就是,我们把任务丢给一个runner,然后runner去帮我们在后台跑这些任务,如果执行任务的过程超时或者收到了中断,我们就报错。
runner的定义
这里我们定义了一个结构体Runner和两种error
[code]var ( ErrTimeout = errors.New("connot finish tasks within the timeout") //超时error ErrInterrupt = errors.New("received interrupt from OS") //中断error)type Runner struct { interrupt chan os.Signal //存放中断信号 complete chan error //放错误 timeout |