Skip to content

Commit

Permalink
fix: fix timewheel
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleiphir2769 committed Jan 30, 2023
1 parent ffb6bc3 commit 5b976f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions timewheel/timewheel.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func (tw *TimeWheel) addTask(task *task) {
func (tw *TimeWheel) getPositionAndCircle(d time.Duration) (pos int, circle int) {
delaySeconds := int(d.Milliseconds())
intervalSeconds := int(tw.interval.Milliseconds())
circle = int(delaySeconds / intervalSeconds / tw.slotNum)
pos = int(tw.currentPos+delaySeconds/intervalSeconds-1) % tw.slotNum
circle = delaySeconds / intervalSeconds / tw.slotNum
pos = (tw.currentPos + delaySeconds/intervalSeconds) % tw.slotNum
if pos < 0 {
pos = 0
}
Expand Down

0 comments on commit 5b976f7

Please sign in to comment.