forked from cerc-io/plugeth
all: use AbsTime.Add instead of conversion (#25417)
This commit is contained in:
@@ -58,7 +58,7 @@ func (s *Simulated) Run(d time.Duration) {
|
||||
s.mu.Lock()
|
||||
s.init()
|
||||
|
||||
end := s.now + AbsTime(d)
|
||||
end := s.now.Add(d)
|
||||
var do []func()
|
||||
for len(s.scheduled) > 0 && s.scheduled[0].at <= end {
|
||||
ev := heap.Pop(&s.scheduled).(*simTimer)
|
||||
@@ -134,7 +134,7 @@ func (s *Simulated) AfterFunc(d time.Duration, fn func()) Timer {
|
||||
func (s *Simulated) schedule(d time.Duration, fn func()) *simTimer {
|
||||
s.init()
|
||||
|
||||
at := s.now + AbsTime(d)
|
||||
at := s.now.Add(d)
|
||||
ev := &simTimer{do: fn, at: at, s: s}
|
||||
heap.Push(&s.scheduled, ev)
|
||||
s.cond.Broadcast()
|
||||
|
||||
@@ -87,13 +87,13 @@ func (q *LazyQueue) Refresh() {
|
||||
|
||||
// refresh re-evaluates items in the older queue and swaps the two queues
|
||||
func (q *LazyQueue) refresh(now mclock.AbsTime) {
|
||||
q.maxUntil = now + mclock.AbsTime(q.period)
|
||||
q.maxUntil = now.Add(q.period)
|
||||
for q.queue[0].Len() != 0 {
|
||||
q.Push(heap.Pop(q.queue[0]).(*item).value)
|
||||
}
|
||||
q.queue[0], q.queue[1] = q.queue[1], q.queue[0]
|
||||
q.indexOffset = 1 - q.indexOffset
|
||||
q.maxUntil += mclock.AbsTime(q.period)
|
||||
q.maxUntil = q.maxUntil.Add(q.period)
|
||||
}
|
||||
|
||||
// Push adds an item to the queue
|
||||
|
||||
Reference in New Issue
Block a user