时间轮清理
This commit is contained in:
parent
d573f458da
commit
7dcbbd3802
@ -21,6 +21,7 @@ type CaravanRank struct {
|
|||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
module *Timer
|
module *Timer
|
||||||
|
cTimerObj *timewheel.Task
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -77,10 +78,10 @@ func (this *CaravanRank) Start() (err error) {
|
|||||||
}
|
}
|
||||||
subTime := int32(configure.Now().Unix() - opentime)
|
subTime := int32(configure.Now().Unix() - opentime)
|
||||||
if subTime < seasonTime {
|
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 {
|
} else {
|
||||||
s := configure.Now().Unix() - (configure.Now().Unix()-opentime)%int64(subTime) + int64(seasonTime)
|
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
|
return
|
||||||
@ -96,24 +97,9 @@ func (this *CaravanRank) TimerSeason(task *timewheel.Task, args ...interface{})
|
|||||||
); err != nil {
|
); err != nil {
|
||||||
this.module.Errorln(err)
|
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())
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user