summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/time_unsafe.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-07-24 01:03:28 +0000
committergVisor bot <gvisor-bot@google.com>2020-07-24 01:03:28 +0000
commit16ab991e05d8f511fc6c7e184751fd330e155950 (patch)
treef6c3ce97f23d8f09d8e3282eb126e9f6b1001f38 /pkg/tcpip/time_unsafe.go
parent4d5f3fb1a454d4421414a355ff94276e1d6e0fdc (diff)
parent82a5cada5944390e738a8b7235fb861965ca40f7 (diff)
Merge release-20200622.1-208-g82a5cada5 (automated)
Diffstat (limited to 'pkg/tcpip/time_unsafe.go')
-rw-r--r--pkg/tcpip/time_unsafe.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/pkg/tcpip/time_unsafe.go b/pkg/tcpip/time_unsafe.go
index 7f172f978..f32d58091 100644
--- a/pkg/tcpip/time_unsafe.go
+++ b/pkg/tcpip/time_unsafe.go
@@ -20,7 +20,7 @@
package tcpip
import (
- _ "time" // Used with go:linkname.
+ "time" // Used with go:linkname.
_ "unsafe" // Required for go:linkname.
)
@@ -45,3 +45,31 @@ func (*StdClock) NowMonotonic() int64 {
_, _, mono := now()
return mono
}
+
+// AfterFunc implements Clock.AfterFunc.
+func (*StdClock) AfterFunc(d time.Duration, f func()) Timer {
+ return &stdTimer{
+ t: time.AfterFunc(d, f),
+ }
+}
+
+type stdTimer struct {
+ t *time.Timer
+}
+
+var _ Timer = (*stdTimer)(nil)
+
+// Stop implements Timer.Stop.
+func (st *stdTimer) Stop() bool {
+ return st.t.Stop()
+}
+
+// Reset implements Timer.Reset.
+func (st *stdTimer) Reset(d time.Duration) {
+ st.t.Reset(d)
+}
+
+// NewStdTimer returns a Timer implemented with the time package.
+func NewStdTimer(t *time.Timer) Timer {
+ return &stdTimer{t: t}
+}