OLD | NEW |
---|---|
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 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 "sync" | 10 "sync" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 d.rwlock.RLock() | 119 d.rwlock.RLock() |
120 defer d.rwlock.RUnlock() | 120 defer d.rwlock.RUnlock() |
121 return d.disableSpecialEntities | 121 return d.disableSpecialEntities |
122 } | 122 } |
123 | 123 |
124 func (d *dataStoreData) getQuerySnaps(consistent bool) (idx, head *memStore) { | 124 func (d *dataStoreData) getQuerySnaps(consistent bool) (idx, head *memStore) { |
125 d.rwlock.RLock() | 125 d.rwlock.RLock() |
126 defer d.rwlock.RUnlock() | 126 defer d.rwlock.RUnlock() |
127 if d.snap == nil { | 127 if d.snap == nil { |
128 // we're 'always consistent' | 128 // we're 'always consistent' |
129 » » return d.head, d.head | 129 » » snap := d.head.Snapshot() |
130 » » return snap, snap | |
iannucci
2015/09/30 03:03:31
This was really dumb on my part. `d.head` is the c
| |
130 } | 131 } |
131 | 132 |
132 head = d.head.Snapshot() | 133 head = d.head.Snapshot() |
133 if consistent { | 134 if consistent { |
134 idx = head | 135 idx = head |
135 } else { | 136 } else { |
136 idx = d.snap | 137 idx = d.snap |
137 } | 138 } |
138 return | 139 return |
139 } | 140 } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 } | 550 } |
550 | 551 |
551 func keyBytes(key *ds.Key) []byte { | 552 func keyBytes(key *ds.Key) []byte { |
552 return serialize.ToBytes(ds.MkProperty(key)) | 553 return serialize.ToBytes(ds.MkProperty(key)) |
553 } | 554 } |
554 | 555 |
555 func rpm(data []byte) (ds.PropertyMap, error) { | 556 func rpm(data []byte) (ds.PropertyMap, error) { |
556 return serialize.ReadPropertyMap(bytes.NewBuffer(data), | 557 return serialize.ReadPropertyMap(bytes.NewBuffer(data), |
557 serialize.WithContext, "", "") | 558 serialize.WithContext, "", "") |
558 } | 559 } |
OLD | NEW |