Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: go/src/infra/gae/libs/wrapper/mathrand.go

Issue 1154213012: Add context-aware "time" library wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Removed goroutine safety from testtimer. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: go/src/infra/gae/libs/wrapper/mathrand.go
diff --git a/go/src/infra/gae/libs/wrapper/mathrand.go b/go/src/infra/gae/libs/wrapper/mathrand.go
index 89c140b77cc59c3df90bf80fb98a1bbd9fd6e7a4..63fed9be93ed6d3f9078d13b860cd8a1e9c75e00 100644
--- a/go/src/infra/gae/libs/wrapper/mathrand.go
+++ b/go/src/infra/gae/libs/wrapper/mathrand.go
@@ -8,6 +8,7 @@ import (
"math/rand"
"golang.org/x/net/context"
+ "infra/libs/clock"
)
// MathRandFactory is the function signature for factory methods compatible with
@@ -16,12 +17,12 @@ type MathRandFactory func(context.Context) *rand.Rand
// GetMathRand gets a *"math/rand".Rand from the context. If one hasn't been
// set, this creates a new Rand object with a Source initialized from the
-// current time accordint to GetTimeNow(c).UnixNano().
+// current time clock.Now(c).UnixNano().
func GetMathRand(c context.Context) *rand.Rand {
if f, ok := c.Value(mathRandKey).(MathRandFactory); ok && f != nil {
return f(c)
}
- return rand.New(rand.NewSource(GetTimeNow(c).UnixNano()))
+ return rand.New(rand.NewSource(clock.Now(c).UnixNano()))
}
// SetMathRandFactory sets the function to produce *"math/rand".Rand instances,

Powered by Google App Engine
This is Rietveld 408576698