runtime, syscall, time: add and use resettimer

As a small step toward speeding up timers, restrict modification
of the timer.when field to the timer code itself. Other code that
wants to change the when field of an existing timer must now call
resettimer rather than changing the when field and calling addtimer.
The new resettimer function also works for a new timer.

This is just a refactoring in preparation for later code.

Updates #27707

Change-Id: Iccd5dcad415ffbeac4c2a3cf015e91f82692acf8
Reviewed-on: https://go-review.googlesource.com/c/go/+/171825
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This commit is contained in:
Ian Lance Taylor 2019-04-10 17:23:05 -07:00
parent 7a6da218b1
commit a7ce2ca52f
5 changed files with 24 additions and 10 deletions

View file

@ -64,8 +64,7 @@ func CheckRuntimeTimerOverflow() {
// once more.
stopTimer(r)
t.Stop()
r.when = 0
startTimer(r)
resetTimer(r, 0)
}()
// If the test fails, we will hang here until the timeout in the testing package