blob: f1203b71c78d6fb1fb093311042decb6dd8ea36d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package cache
import "sync"
var (
ExportMockRemovalCounter = &mockCounter{}
ExportMockCheckCounter = &mockCounter{}
ExportMockLoserBytes = &mockCounter{}
ExportDisableMoveAndClear = &disableMoveAndClear
ExportDisableWalker = &disableWalker
)
type mockCounter struct {
sync.RWMutex
count int
}
func (mc *mockCounter) Add(n int) {
mc.Lock()
mc.count += n
mc.Unlock()
}
func (mc *mockCounter) Count() int {
mc.RLock()
defer mc.RUnlock()
return mc.count
}
func init() {
// override counter functions with our mocked version
countWalkRemoval = func() { ExportMockRemovalCounter.Add(1) }
countWalkCheck = func() { ExportMockCheckCounter.Add(1) }
countLoserBytes = func(n float64) { ExportMockLoserBytes.Add(int(n)) }
}
|