1 Star 4 Fork 0

magicianlyx/GoTask

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
singletask.go 652 Bytes
Copy Edit Raw Blame History
magicianlyx authored 2021-11-20 21:16 +08:00 . -
package GoTask
import (
"time"
)
// 指定执行次数定时任务
type MultiTask struct {
*TimedTask
}
func NewMultiTask(routineCount int) *MultiTask {
return &MultiTask{NewTimedTask(routineCount)}
}
func (mt *MultiTask) Add(key string, task Func, spec int, count int) {
mt.TimedTask.Add(key, task, NewSpecTimeSchedule(time.Duration(spec)*time.Second, count))
}
// 指定只执行一次定时任务
type SingleTask struct {
*MultiTask
}
func NewSingleTask(routineCount int) *SingleTask {
return &SingleTask{NewMultiTask(routineCount)}
}
func (st *SingleTask) Add(key string, task Func, spec int) {
st.MultiTask.Add(key, task, spec, 1)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/magicianlyx/GoTask.git
git@gitee.com:magicianlyx/GoTask.git
magicianlyx
GoTask
GoTask
v1.0.15

Search