diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-04-10 17:23:05 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-10-21 17:06:22 +0000 |
commit | a7ce2ca52f6de38e7db0a67bbdf697a6b5dc122a (patch) | |
tree | 2cc39783637634d8d8df9f859e5ead005d68de64 /src/runtime/netpoll.go | |
parent | 7a6da218b191de13f4f3555c55aab958b09b66bd (diff) | |
download | go-a7ce2ca52f6de38e7db0a67bbdf697a6b5dc122a.tar.gz go-a7ce2ca52f6de38e7db0a67bbdf697a6b5dc122a.zip |
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>
Diffstat (limited to 'src/runtime/netpoll.go')
-rw-r--r-- | src/runtime/netpoll.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go index 7d18dcaeea..536dae3d4f 100644 --- a/src/runtime/netpoll.go +++ b/src/runtime/netpoll.go @@ -239,13 +239,12 @@ func poll_runtime_pollSetDeadline(pd *pollDesc, d int64, mode int) { if pd.rt.f == nil { if pd.rd > 0 { pd.rt.f = rtf - pd.rt.when = pd.rd // Copy current seq into the timer arg. // Timer func will check the seq against current descriptor seq, // if they differ the descriptor was reused or timers were reset. pd.rt.arg = pd pd.rt.seq = pd.rseq - addtimer(&pd.rt) + resettimer(&pd.rt, pd.rd) } } else if pd.rd != rd0 || combo != combo0 { pd.rseq++ // invalidate current timers @@ -259,10 +258,9 @@ func poll_runtime_pollSetDeadline(pd *pollDesc, d int64, mode int) { if pd.wt.f == nil { if pd.wd > 0 && !combo { pd.wt.f = netpollWriteDeadline - pd.wt.when = pd.wd pd.wt.arg = pd pd.wt.seq = pd.wseq - addtimer(&pd.wt) + resettimer(&pd.wt, pd.wd) } } else if pd.wd != wd0 || combo != combo0 { pd.wseq++ // invalidate current timers |