common/mclock: remove dependency on github.com/aristanetworks/goarista (#22211)

It takes three lines of code to get to runtime.nanotime, no need to
pull a dependency for that.
This commit is contained in:
Felix Lange
2021-01-22 20:15:27 +01:00
committed by GitHub
parent 9e1bd0f367
commit f26c19cbcd
4 changed files with 9 additions and 7 deletions

View File

@ -20,15 +20,19 @@ package mclock
import (
"time"
"github.com/aristanetworks/goarista/monotime"
_ "unsafe" // for go:linkname
)
//go:noescape
//go:linkname nanotime runtime.nanotime
func nanotime() int64
// AbsTime represents absolute monotonic time.
type AbsTime time.Duration
type AbsTime int64
// Now returns the current absolute monotonic time.
func Now() AbsTime {
return AbsTime(monotime.Now())
return AbsTime(nanotime())
}
// Add returns t + d as absolute time.
@ -74,7 +78,7 @@ type System struct{}
// Now returns the current monotonic time.
func (c System) Now() AbsTime {
return AbsTime(monotime.Now())
return Now()
}
// Sleep blocks for the given duration.