1 Star 0 Fork 0

kzangv/gsf-fof

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
entry.go 1007 Bytes
一键复制 编辑 原始数据 按行查看 历史
kzangv 提交于 2023-02-23 10:22 . fixed
package cron
import (
"gitee.com/kzangv/gsf-fof/component/cron/schedule"
"time"
)
type Job interface {
Init()
Run(time.Time)
Destroy()
}
type ScheduleJob interface {
schedule.Interface
Job
}
type ScheduleRun func(t time.Time)
type WrapJob ScheduleRun
func (f WrapJob) Init() {}
func (f WrapJob) Run(t time.Time) { f(t) }
func (f WrapJob) Destroy() {}
type WrapScheduleJob struct {
Job
schedule.Interface
}
type entry struct {
Name string
Schedule ScheduleJob
Next time.Time
Prev time.Time
}
type entries []*entry
func (pq entries) Len() int {
return len(pq)
}
func (pq entries) Less(i, j int) bool {
return pq[i].Next.Before(pq[j].Next)
}
func (pq entries) Swap(i, j int) {
pq[i], pq[j] = pq[j], pq[i]
}
func (pq *entries) Push(x interface{}) {
item := x.(*entry)
*pq = append(*pq, item)
}
func (pq *entries) Pop() interface{} {
old := *pq
n := len(old)
item := old[n-1]
old[n-1] = nil // avoid memory leak
*pq = old[0 : n-1]
return item
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kzangv/gsf-fof.git
git@gitee.com:kzangv/gsf-fof.git
kzangv
gsf-fof
gsf-fof
v0.4.2

搜索帮助

0d507c66 1850385 C8b1a773 1850385