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

Side by Side Diff: impl/memory/taskqueue_data.go

Issue 1282673002: Make obtaining the Testable interface actually part of the interface. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « impl/memory/taskqueue.go ('k') | impl/memory/taskqueue_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package memory 5 package memory
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "fmt" 9 "fmt"
10 "net/http" 10 "net/http"
(...skipping 14 matching lines...) Expand all
25 25
26 //////////////////////////////// taskQueueData ///////////////////////////////// 26 //////////////////////////////// taskQueueData /////////////////////////////////
27 27
28 type taskQueueData struct { 28 type taskQueueData struct {
29 sync.Mutex 29 sync.Mutex
30 30
31 named tq.QueueData 31 named tq.QueueData
32 archived tq.QueueData 32 archived tq.QueueData
33 } 33 }
34 34
35 var ( 35 var _ interface {
36 » _ = memContextObj((*taskQueueData)(nil)) 36 » memContextObj
37 » _ = tq.Testable((*taskQueueData)(nil)) 37 » tq.Testable
38 ) 38 } = (*taskQueueData)(nil)
39 39
40 func newTaskQueueData() memContextObj { 40 func newTaskQueueData() memContextObj {
41 return &taskQueueData{ 41 return &taskQueueData{
42 named: tq.QueueData{"default": {}}, 42 named: tq.QueueData{"default": {}},
43 archived: tq.QueueData{"default": {}}, 43 archived: tq.QueueData{"default": {}},
44 } 44 }
45 } 45 }
46 46
47 func (t *taskQueueData) canApplyTxn(obj memContextObj) bool { return true } 47 func (t *taskQueueData) canApplyTxn(obj memContextObj) bool { return true }
48 func (t *taskQueueData) endTxn() {} 48 func (t *taskQueueData) endTxn() {}
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 type txnTaskQueueData struct { 185 type txnTaskQueueData struct {
186 lock sync.Mutex 186 lock sync.Mutex
187 187
188 // boolean 0 or 1, use atomic.*Int32 to access. 188 // boolean 0 or 1, use atomic.*Int32 to access.
189 closed int32 189 closed int32
190 anony tq.AnonymousQueueData 190 anony tq.AnonymousQueueData
191 parent *taskQueueData 191 parent *taskQueueData
192 } 192 }
193 193
194 var ( 194 var _ interface {
195 » _ = memContextObj((*txnTaskQueueData)(nil)) 195 » memContextObj
196 » _ = tq.Testable((*txnTaskQueueData)(nil)) 196 » tq.Testable
197 ) 197 } = (*txnTaskQueueData)(nil)
198 198
199 func (t *txnTaskQueueData) canApplyTxn(obj memContextObj) bool { return false } 199 func (t *txnTaskQueueData) canApplyTxn(obj memContextObj) bool { return false }
200 func (t *txnTaskQueueData) applyTxn(context.Context, memContextObj) { panic(" impossible") } 200 func (t *txnTaskQueueData) applyTxn(context.Context, memContextObj) { panic(" impossible") }
201 func (t *txnTaskQueueData) mkTxn(*ds.TransactionOptions) memContextObj { panic(" impossible") } 201 func (t *txnTaskQueueData) mkTxn(*ds.TransactionOptions) memContextObj { panic(" impossible") }
202 202
203 func (t *txnTaskQueueData) endTxn() { 203 func (t *txnTaskQueueData) endTxn() {
204 if atomic.LoadInt32(&t.closed) == 1 { 204 if atomic.LoadInt32(&t.closed) == 1 {
205 panic("cannot end transaction twice") 205 panic("cannot end transaction twice")
206 } 206 }
207 atomic.StoreInt32(&t.closed, 1) 207 atomic.StoreInt32(&t.closed, 1)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return t.parent.GetTombstonedTasks() 247 return t.parent.GetTombstonedTasks()
248 } 248 }
249 249
250 func (t *txnTaskQueueData) GetScheduledTasks() tq.QueueData { 250 func (t *txnTaskQueueData) GetScheduledTasks() tq.QueueData {
251 return t.parent.GetScheduledTasks() 251 return t.parent.GetScheduledTasks()
252 } 252 }
253 253
254 func (t *txnTaskQueueData) CreateQueue(queueName string) { 254 func (t *txnTaskQueueData) CreateQueue(queueName string) {
255 t.parent.CreateQueue(queueName) 255 t.parent.CreateQueue(queueName)
256 } 256 }
OLDNEW
« no previous file with comments | « impl/memory/taskqueue.go ('k') | impl/memory/taskqueue_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698