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

Unified Diff: go/src/infra/gae/libs/wrapper/memory/context.go

Issue 1154213012: Add context-aware "time" library wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Added coverage files. 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
« no previous file with comments | « go/src/infra/gae/libs/wrapper/mathrand.go ('k') | go/src/infra/gae/libs/wrapper/memory/datastore_data.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/wrapper/memory/context.go
diff --git a/go/src/infra/gae/libs/wrapper/memory/context.go b/go/src/infra/gae/libs/wrapper/memory/context.go
index 241d2a24edc1b09019731be9cb17c83c60b70005..b6607fcc4d0231f8b23874083be039c09a157545 100644
--- a/go/src/infra/gae/libs/wrapper/memory/context.go
+++ b/go/src/infra/gae/libs/wrapper/memory/context.go
@@ -6,8 +6,6 @@ package memory
import (
"errors"
- "infra/gae/libs/wrapper"
- "math/rand"
"sync"
"golang.org/x/net/context"
@@ -18,7 +16,7 @@ import (
type memContextObj interface {
sync.Locker
canApplyTxn(m memContextObj) bool
- applyTxn(rnd *rand.Rand, m memContextObj)
+ applyTxn(c context.Context, m memContextObj)
endTxn()
mkTxn(*datastore.TransactionOptions) (memContextObj, error)
@@ -86,10 +84,10 @@ func (m memContext) canApplyTxn(txnCtxObj memContextObj) bool {
return true
}
-func (m memContext) applyTxn(rnd *rand.Rand, txnCtxObj memContextObj) {
+func (m memContext) applyTxn(c context.Context, txnCtxObj memContextObj) {
txnCtx := txnCtxObj.(memContext)
for i := range m {
- m[i].applyTxn(rnd, txnCtx[i])
+ m[i].applyTxn(c, txnCtx[i])
}
}
@@ -162,7 +160,7 @@ func (d *dsImpl) RunInTransaction(f func(context.Context) error, o *datastore.Tr
defer txnMC.Unlock()
if curMC.canApplyTxn(txnMC) {
- curMC.applyTxn(wrapper.GetMathRand(d.c), txnMC)
+ curMC.applyTxn(d.c, txnMC)
} else {
return datastore.ErrConcurrentTransaction
}
« no previous file with comments | « go/src/infra/gae/libs/wrapper/mathrand.go ('k') | go/src/infra/gae/libs/wrapper/memory/datastore_data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698