aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/time.go
diff options
context:
space:
mode:
authorChangkun Ou <hi@changkun.us>2020-02-03 14:42:32 +0100
committerIan Lance Taylor <iant@golang.org>2020-02-23 16:09:02 +0000
commit6e5652bebede2d53484a872f6d1dfeb498b0b50c (patch)
tree09afe930fe45f4238275e2e28df44a44fa82acb9 /src/runtime/time.go
parentebe49b2c2999a7d4128c44aed9602a69fdc53d16 (diff)
downloadgo-6e5652bebede2d53484a872f6d1dfeb498b0b50c.tar.gz
go-6e5652bebede2d53484a872f6d1dfeb498b0b50c.zip
time: add Ticker.Reset
This CL implements Ticker.Reset method in time package. Benchmark: name time/op TickerReset-12 6.41µs ±10% TickerResetNaive-12 95.7µs ±12% Fixes #33184 Change-Id: I12c651f81e452541bcbbc748b45f038aae1f8dae Reviewed-on: https://go-review.googlesource.com/c/go/+/217362 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/time.go')
-rw-r--r--src/runtime/time.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/runtime/time.go b/src/runtime/time.go
index af5db4cc58..9e1129537a 100644
--- a/src/runtime/time.go
+++ b/src/runtime/time.go
@@ -233,6 +233,12 @@ func resetTimer(t *timer, when int64) {
resettimer(t, when)
}
+// modTimer modifies an existing timer.
+//go:linkname modTimer time.modTimer
+func modTimer(t *timer, when, period int64, f func(interface{}, uintptr), arg interface{}, seq uintptr) {
+ modtimer(t, when, period, f, arg, seq)
+}
+
// Go runtime.
// Ready the goroutine arg.
@@ -402,7 +408,7 @@ func dodeltimer0(pp *p) bool {
}
// modtimer modifies an existing timer.
-// This is called by the netpoll code.
+// This is called by the netpoll code or time.Ticker.Reset.
func modtimer(t *timer, when, period int64, f func(interface{}, uintptr), arg interface{}, seq uintptr) {
if when < 0 {
when = maxWhen