| 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() {} |
| 72 |
| 71 func newMemStore() *memStore { | 73 func newMemStore() *memStore { |
| 72 ret, err := gkvlite.NewStore(nil) | 74 ret, err := gkvlite.NewStore(nil) |
| 73 memoryCorruption(err) | 75 memoryCorruption(err) |
| 74 return (*memStore)(ret) | 76 return (*memStore)(ret) |
| 75 } | 77 } |
| 76 | 78 |
| 77 func (ms *memStore) Snapshot() *memStore { | 79 func (ms *memStore) Snapshot() *memStore { |
| 78 ret := (*memStore)((*gkvlite.Store)(ms).Snapshot()) | 80 ret := (*memStore)((*gkvlite.Store)(ms).Snapshot()) |
| 79 runtime.SetFinalizer((*gkvlite.Store)(ret), func(s *gkvlite.Store) { | 81 runtime.SetFinalizer((*gkvlite.Store)(ret), func(s *gkvlite.Store) { |
| 80 go s.Close() | 82 go s.Close() |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 func (mc *memCollection) VisitItemsAscend(target []byte, withValue bool, visitor
gkvlite.ItemVisitor) { | 134 func (mc *memCollection) VisitItemsAscend(target []byte, withValue bool, visitor
gkvlite.ItemVisitor) { |
| 133 err := (*gkvlite.Collection)(mc).VisitItemsAscend(target, withValue, vis
itor) | 135 err := (*gkvlite.Collection)(mc).VisitItemsAscend(target, withValue, vis
itor) |
| 134 memoryCorruption(err) | 136 memoryCorruption(err) |
| 135 } | 137 } |
| 136 | 138 |
| 137 func (mc *memCollection) GetTotals() (numItems, numBytes uint64) { | 139 func (mc *memCollection) GetTotals() (numItems, numBytes uint64) { |
| 138 numItems, numBytes, err := (*gkvlite.Collection)(mc).GetTotals() | 140 numItems, numBytes, err := (*gkvlite.Collection)(mc).GetTotals() |
| 139 memoryCorruption(err) | 141 memoryCorruption(err) |
| 140 return | 142 return |
| 141 } | 143 } |
| OLD | NEW |