aboutsummaryrefslogtreecommitdiff
path: root/src/time
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2024-02-14 11:57:05 -0500
committerGopher Robot <gobot@golang.org>2024-02-29 18:51:47 +0000
commitadc575e64c8a49c0a14a8a6b0480c5f9815bdb1a (patch)
treeffcfd0f85057c6844631632d9e3c6323581aa838 /src/time
parent8570aaaf1a1f6cf18c146d7f66016b491847f7f7 (diff)
downloadgo-adc575e64c8a49c0a14a8a6b0480c5f9815bdb1a.tar.xz
runtime: move per-P timers state into its own struct
Continuing conversion from C to Go, introduce type timers encapsulating all timer heap state, with methods for operations. This should at least be easier to think about, instead of having these fields strewn through the P struct. It should also be easier to test. I am skeptical about the pair of atomic int64 deadlines: I think there are missed wakeups lurking. Having the code in an abstracted API should make it easier to reason through and fix if needed. [This is one CL in a refactoring stack making very small changes in each step, so that any subtle bugs that we miss can be more easily pinpointed to a small change.] Change-Id: If5ea3e0b946ca14076f44c85cbb4feb9eddb4f95 Reviewed-on: https://go-review.googlesource.com/c/go/+/564132 Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/time')
-rw-r--r--src/time/sleep.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/time/sleep.go b/src/time/sleep.go
index ffc69bcd2a..bd78de9fd3 100644
--- a/src/time/sleep.go
+++ b/src/time/sleep.go
@@ -4,6 +4,8 @@
package time
+import "unsafe"
+
// Sleep pauses the current goroutine for at least the duration d.
// A negative or zero duration causes Sleep to return immediately.
func Sleep(d Duration)
@@ -11,7 +13,7 @@ func Sleep(d Duration)
// Interface to timers implemented in package runtime.
// Must be in sync with ../runtime/time.go:/^type timer
type runtimeTimer struct {
- pp uintptr
+ ts unsafe.Pointer
when int64
period int64
f func(any, uintptr) // NOTE: must not be closure