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 "runtime" | 9 "runtime" |
10 "sync" | 10 "sync" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 // memStore is a gkvlite.Store which will panic for anything which might | 63 // memStore is a gkvlite.Store which will panic for anything which might |
64 // otherwise return an error. | 64 // otherwise return an error. |
65 // | 65 // |
66 // This is reasonable for in-memory Store objects, since the only errors that | 66 // This is reasonable for in-memory Store objects, since the only errors that |
67 // should occur happen with file IO on the underlying file (which of course | 67 // should occur happen with file IO on the underlying file (which of course |
68 // doesn't exist). | 68 // doesn't exist). |
69 type memStore gkvlite.Store | 69 type memStore gkvlite.Store |
70 | 70 |
71 func (memStore) ImATestingSnapshot() {} | 71 func (*memStore) ImATestingSnapshot() {} |
72 | 72 |
73 func newMemStore() *memStore { | 73 func newMemStore() *memStore { |
74 ret, err := gkvlite.NewStore(nil) | 74 ret, err := gkvlite.NewStore(nil) |
75 memoryCorruption(err) | 75 memoryCorruption(err) |
76 return (*memStore)(ret) | 76 return (*memStore)(ret) |
77 } | 77 } |
78 | 78 |
79 func (ms *memStore) Snapshot() *memStore { | 79 func (ms *memStore) Snapshot() *memStore { |
80 ret := (*memStore)((*gkvlite.Store)(ms).Snapshot()) | 80 ret := (*memStore)((*gkvlite.Store)(ms).Snapshot()) |
81 runtime.SetFinalizer((*gkvlite.Store)(ret), func(s *gkvlite.Store) { | 81 runtime.SetFinalizer((*gkvlite.Store)(ret), func(s *gkvlite.Store) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 func (mc *memCollection) VisitItemsAscend(target []byte, withValue bool, visitor
gkvlite.ItemVisitor) { | 134 func (mc *memCollection) VisitItemsAscend(target []byte, withValue bool, visitor
gkvlite.ItemVisitor) { |
135 err := (*gkvlite.Collection)(mc).VisitItemsAscend(target, withValue, vis
itor) | 135 err := (*gkvlite.Collection)(mc).VisitItemsAscend(target, withValue, vis
itor) |
136 memoryCorruption(err) | 136 memoryCorruption(err) |
137 } | 137 } |
138 | 138 |
139 func (mc *memCollection) GetTotals() (numItems, numBytes uint64) { | 139 func (mc *memCollection) GetTotals() (numItems, numBytes uint64) { |
140 numItems, numBytes, err := (*gkvlite.Collection)(mc).GetTotals() | 140 numItems, numBytes, err := (*gkvlite.Collection)(mc).GetTotals() |
141 memoryCorruption(err) | 141 memoryCorruption(err) |
142 return | 142 return |
143 } | 143 } |
OLD | NEW |