1 Star 0 Fork 0

collin/leaf

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
timer.go 521 Bytes
一键复制 编辑 原始数据 按行查看 历史
collin 提交于 2021-10-09 11:54 +08:00 . adjust file structure
package timer
import (
"runtime"
"time"
"gitee.com/nbcx/leaf/conf"
"gitee.com/nbcx/leaf/log"
)
// Timer
type Timer struct {
t *time.Timer
cb func()
}
func (t *Timer) Stop() {
t.t.Stop()
t.cb = nil
}
func (t *Timer) Cb() {
defer func() {
t.cb = nil
if r := recover(); r != nil {
if conf.LenStackBuf > 0 {
buf := make([]byte, conf.LenStackBuf)
l := runtime.Stack(buf, false)
log.Error("%v: %s", r, buf[:l])
} else {
log.Error("%v", r)
}
}
}()
if t.cb != nil {
t.cb()
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nbcx/leaf.git
git@gitee.com:nbcx/leaf.git
nbcx
leaf
leaf
78613ecb5808

搜索帮助