Skip to content

Commit d6ee49a

Browse files
committed
fix bug in tick
Fixes #576. R=rsc, rog CC=golang-dev https://golang.org/cl/196061
1 parent 4ffbff1 commit d6ee49a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/pkg/time/tick.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func (a *alarmer) set(ns int64) {
4747
}
4848
a.wakeMeAt = make(chan int64, 10)
4949
go wakeLoop(a.wakeMeAt, a.wakeUp)
50+
a.wakeTime = ns
5051
a.wakeMeAt <- ns
5152
}
5253
}
@@ -117,7 +118,7 @@ func tickerLoop() {
117118
}
118119
continue
119120
}
120-
if tickers.nextTick <= now {
121+
if t.nextTick <= now {
121122
if len(t.c) == 0 {
122123
// Only send if there's room. We must not block.
123124
// The channel is allocated with a one-element
@@ -130,9 +131,9 @@ func tickerLoop() {
130131
// Still behind; advance in one big step.
131132
t.nextTick += (now - t.nextTick + t.ns) / t.ns * t.ns
132133
}
133-
if t.nextTick > now && t.nextTick < wakeTime {
134-
wakeTime = t.nextTick
135-
}
134+
}
135+
if t.nextTick < wakeTime {
136+
wakeTime = t.nextTick
136137
}
137138
prev = t
138139
}

0 commit comments

Comments
 (0)