1
0
mirror of https://github.com/golang/go synced 2024-11-24 09:10:24 -07:00

fix bug in tick

Fixes #576.

R=rsc, rog
CC=golang-dev
https://golang.org/cl/196061
This commit is contained in:
Rob Pike 2010-01-29 13:10:33 -08:00
parent 4ffbff14b3
commit d6ee49a119

View File

@ -47,6 +47,7 @@ func (a *alarmer) set(ns int64) {
}
a.wakeMeAt = make(chan int64, 10)
go wakeLoop(a.wakeMeAt, a.wakeUp)
a.wakeTime = ns
a.wakeMeAt <- ns
}
}
@ -117,7 +118,7 @@ func tickerLoop() {
}
continue
}
if tickers.nextTick <= now {
if t.nextTick <= now {
if len(t.c) == 0 {
// Only send if there's room. We must not block.
// The channel is allocated with a one-element
@ -130,9 +131,9 @@ func tickerLoop() {
// Still behind; advance in one big step.
t.nextTick += (now - t.nextTick + t.ns) / t.ns * t.ns
}
if t.nextTick > now && t.nextTick < wakeTime {
wakeTime = t.nextTick
}
}
if t.nextTick < wakeTime {
wakeTime = t.nextTick
}
prev = t
}