aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/lock_js.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2021-04-07 10:15:33 -0400
committerMichael Pratt <mpratt@google.com>2021-04-16 21:03:44 +0000
commitf6e7fe2711849e2e57f79b89ee7928b8806618c8 (patch)
treea26e3286bdaa1f302611bf0c7b50f338ad154264 /src/runtime/lock_js.go
parent9fbcba6664840ada5aaedb7f1a587d0cca1c9035 (diff)
downloadgo-f6e7fe2711849e2e57f79b89ee7928b8806618c8.tar.gz
go-f6e7fe2711849e2e57f79b89ee7928b8806618c8.zip
runtime: move findrunnable timer delay computation closer to use
findrunnable has a couple places where delta is recomputed from a new pollUntil value. This proves to be a pain in refactoring, as it is easy to forget to do properly. Move computation of delta closer to its use, where it is more logical anyways. This CL should have no functional changes. For #43997. For #44313. Change-Id: I89980fd7f40f8a4c56c7540cae03ff99e12e1422 Reviewed-on: https://go-review.googlesource.com/c/go/+/307910 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/lock_js.go')
-rw-r--r--src/runtime/lock_js.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/runtime/lock_js.go b/src/runtime/lock_js.go
index 04e7e85c12..0ca3512baf 100644
--- a/src/runtime/lock_js.go
+++ b/src/runtime/lock_js.go
@@ -176,7 +176,12 @@ var idleID int32
// If an event handler returned, we resume it and it will pause the execution.
// beforeIdle either returns the specific goroutine to schedule next or
// indicates with otherReady that some goroutine became ready.
-func beforeIdle(delay int64) (gp *g, otherReady bool) {
+func beforeIdle(now, pollUntil int64) (gp *g, otherReady bool) {
+ delay := int64(-1)
+ if pollUntil != 0 {
+ delay = pollUntil - now
+ }
+
if delay > 0 {
clearIdleID()
if delay < 1e6 {