]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "time: add Ticker.Reset"
authorAndrew Bonventre <andybons@golang.org>
Sun, 23 Feb 2020 17:28:56 +0000 (17:28 +0000)
committerIan Lance Taylor <iant@golang.org>
Sun, 23 Feb 2020 17:58:14 +0000 (17:58 +0000)
This reverts CL 217362 (6e5652bebede2d53484a872f6d1dfeb498b0b50c.)

Reason for revert: Causing failures on arm64 bots. See #33184 for more info

Change-Id: I72ba40047e4138767d95aaa68842893c3508c52f
Reviewed-on: https://go-review.googlesource.com/c/go/+/220638
Reviewed-by: Ian Lance Taylor <iant@golang.org>
api/next.txt
doc/go1.15.html
src/runtime/time.go
src/time/sleep.go
src/time/tick.go
src/time/tick_test.go

index cab86a9904184fdb4b022bbbbe627ee8b8ce13f3..ecc3c4f0b69cbeb0322d114eda8ca3d41d3cfce3 100644 (file)
@@ -1,2 +1 @@
 pkg testing, method (*T) Deadline() (time.Time, bool)
-pkg time, method (*Ticker) Reset(Duration)
index ed240d85ccae33925ff421976db0ac7f2da7ab3f..a3a089e07e664aee05b2bf84288556f90987b0b9 100644 (file)
@@ -80,13 +80,3 @@ TODO
 <p>
 TODO
 </p>
-
-<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
-  <dd>
-    <p><!-- golang.org/issue/33184 -->
-       The new method
-       <a href="/pkg/time#Ticker.Reset"><code>Ticker.Reset</code></a>
-       supports changing the duration of a ticker.
-    </p>
-  </dd>
-</dl><!-- time -->
index 9e1129537a7ac1329faf0041ce7af1ef9430878c..af5db4cc58b761c17f1d641be422bf9daf7a3047 100644 (file)
@@ -233,12 +233,6 @@ 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.
@@ -408,7 +402,7 @@ func dodeltimer0(pp *p) bool {
 }
 
 // modtimer modifies an existing timer.
-// This is called by the netpoll code or time.Ticker.Reset.
+// This is called by the netpoll code.
 func modtimer(t *timer, when, period int64, f func(interface{}, uintptr), arg interface{}, seq uintptr) {
        if when < 0 {
                when = maxWhen
index bd0ed9aaba88acbc948cce31d908f89e8f7dba4c..37de846b114a88194e4beec43d80497b1391cdd2 100644 (file)
@@ -39,7 +39,6 @@ func when(d Duration) int64 {
 func startTimer(*runtimeTimer)
 func stopTimer(*runtimeTimer) bool
 func resetTimer(*runtimeTimer, int64)
-func modTimer(t *runtimeTimer, when, period int64, f func(interface{}, uintptr), arg interface{}, seq uintptr)
 
 // The Timer type represents a single event.
 // When the Timer expires, the current time will be sent on C,
index 152d5a706be4e0daba0404de4058706f803a6bd1..e4cd43aa82aef5b6ec2de6542bbf5dfbd122bd25 100644 (file)
@@ -46,15 +46,6 @@ func (t *Ticker) Stop() {
        stopTimer(&t.r)
 }
 
-// Reset stops a ticker and resets its period to the specified duration.
-// The next tick will arrive after the new period elapses.
-func (t *Ticker) Reset(d Duration) {
-       if t.r.f == nil {
-               panic("time: Reset called on uninitialized Ticker")
-       }
-       modTimer(&t.r, when(d), int64(d), t.r.f, t.r.arg, t.r.seq)
-}
-
 // Tick is a convenience wrapper for NewTicker providing access to the ticking
 // channel only. While Tick is useful for clients that have no need to shut down
 // the Ticker, be aware that without a way to shut it down the underlying
index d05b345efb6110a6527903a2810d9506761eab44..71ea3672b86645a4d8d35e9be033f39930d468a8 100644 (file)
@@ -36,17 +36,13 @@ func TestTicker(t *testing.T) {
        for i := 0; i < 5; i++ {
                ticker := NewTicker(delta)
                t0 := Now()
-               for i := 0; i < count/2; i++ {
-                       <-ticker.C
-               }
-               ticker.Reset(delta * 2)
-               for i := count / 2; i < count; i++ {
+               for i := 0; i < count; i++ {
                        <-ticker.C
                }
                ticker.Stop()
                t1 := Now()
                dt := t1.Sub(t0)
-               target := 3 * delta * Duration(count/2)
+               target := delta * Duration(count)
                slop := target * 2 / 10
                if dt < target-slop || dt > target+slop {
                        errs = append(errs, fmt.Sprintf("%d %s ticks took %s, expected [%s,%s]", count, delta, dt, target-slop, target+slop))
@@ -122,24 +118,3 @@ func BenchmarkTicker(b *testing.B) {
                ticker.Stop()
        })
 }
-
-func BenchmarkTickerReset(b *testing.B) {
-       benchmark(b, func(n int) {
-               ticker := NewTicker(Nanosecond)
-               for i := 0; i < n; i++ {
-                       ticker.Reset(Nanosecond * 2)
-               }
-               ticker.Stop()
-       })
-}
-
-func BenchmarkTickerResetNaive(b *testing.B) {
-       benchmark(b, func(n int) {
-               ticker := NewTicker(Nanosecond)
-               for i := 0; i < n; i++ {
-                       ticker.Stop()
-                       ticker = NewTicker(Nanosecond * 2)
-               }
-               ticker.Stop()
-       })
-}