时间轮清理

This commit is contained in:
meixiongfeng 2023-05-23 17:08:03 +08:00
parent d573f458da
commit 7dcbbd3802

View File

@ -19,8 +19,9 @@ import (
type CaravanRank struct {
cbase.ModuleBase
modules.MCompModel
service base.IRPCXService
module *Timer
service base.IRPCXService
module *Timer
cTimerObj *timewheel.Task
}
const (
@ -77,10 +78,10 @@ func (this *CaravanRank) Start() (err error) {
}
subTime := int32(configure.Now().Unix() - opentime)
if subTime < seasonTime {
timewheel.Add(time.Second*time.Duration(subTime), this.TimerSeason, nil)
this.cTimerObj = timewheel.Add(time.Second*time.Duration(subTime), this.TimerSeason, nil)
} else {
s := configure.Now().Unix() - (configure.Now().Unix()-opentime)%int64(subTime) + int64(seasonTime)
timewheel.Add(time.Second*time.Duration(s), this.TimerSeason, nil)
this.cTimerObj = timewheel.Add(time.Second*time.Duration(s), this.TimerSeason, nil)
}
return
@ -96,24 +97,9 @@ func (this *CaravanRank) TimerSeason(task *timewheel.Task, args ...interface{})
); err != nil {
this.module.Errorln(err)
}
if this.cTimerObj != nil {
timewheel.Remove(this.cTimerObj)
} // 重新开启一个时间轮
this.cTimerObj = timewheel.Add(time.Second*time.Duration(this.GetGlobalConf().BusinessRewardday), this.TimerSeason, nil)
// if _data, err := this.DB.Find(comm.TableUser, bson.M{"merchantmoney": bson.M{"$gt": 0}}); err == nil {
// for _data.Next(context.TODO()) {
// temp := &pb.DBUser{}
// if err = _data.Decode(temp); err == nil {
// }
// }
// }
// sTime := time.Now()
// Query := bson.M{}
// Query["merchantmoney"] = 0
// _, err := this.DB.UpdateMany(core.SqlTable(comm.TableUser), bson.M{}, bson.M{"$set": Query}, options.MergeUpdateOptions().SetUpsert(true)) //, new(options.UpdateOptions).SetUpsert(true)
// if err != nil {
// this.module.Errorf("UpdateMany error: %v", err)
// }
// this.module.Debugf("sub time:%d", time.Now().Local().Sub(sTime).Milliseconds())
}