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

Side by Side Diff: tools/slab/slab_test.go

Issue 1409173004: Remove usage of unsafe from gkvlite (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gkvlite.git@master
Patch Set: get locks out of other lock Created 5 years, 2 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 | « tools/slab/slab.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package main 1 package main
2 2
3 // Test integration of gkvlite with go-slab, using gkvlite's optional 3 // Test integration of gkvlite with go-slab, using gkvlite's optional
4 // ItemAddRef/ItemDecRef() callbacks to integrate with a slab memory 4 // ItemAddRef/ItemDecRef() callbacks to integrate with a slab memory
5 // allocator. 5 // allocator.
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "math/rand" 10 "math/rand"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if scb.ItemValLength(x, i) != kr4 { 142 if scb.ItemValLength(x, i) != kr4 {
143 t.Errorf("expected len: %d, got %d", 143 t.Errorf("expected len: %d, got %d",
144 kr4, scb.ItemValLength(x , i)) 144 kr4, scb.ItemValLength(x , i))
145 } 145 }
146 s.ItemDecRef(x, i) 146 s.ItemDecRef(x, i)
147 } 147 }
148 } else if r < 60 { 148 } else if r < 60 {
149 numSets++ 149 numSets++
150 b := arena.Alloc(kr * kr * kr * kr) 150 b := arena.Alloc(kr * kr * kr * kr)
151 pri := rand.Int31() 151 pri := rand.Int31()
152 » » » » it := scb.ItemAlloc(x, uint16(len(k))) 152 » » » » it := scb.ItemAlloc(x, uint32(len(k)))
153 copy(it.Key, k) 153 copy(it.Key, k)
154 it.Val = b 154 it.Val = b
155 it.Priority = pri 155 it.Priority = pri
156 err := x.SetItem(it) 156 err := x.SetItem(it)
157 if err != nil { 157 if err != nil {
158 t.Errorf("expected nil error, got: %v", err) 158 t.Errorf("expected nil error, got: %v", err)
159 } 159 }
160 scb.ItemDecRef(x, it) 160 scb.ItemDecRef(x, it)
161 } else if r < 80 { 161 } else if r < 80 {
162 _, err := x.Delete(k) 162 _, err := x.Delete(k)
(...skipping 11 matching lines...) Expand all
174 } 174 }
175 x.EvictSomeItems() 175 x.EvictSomeItems()
176 for k := 0; k < numKeys; k++ { 176 for k := 0; k < numKeys; k++ {
177 _, err := x.Delete([]byte(fmt.Sprintf("%03d", k))) 177 _, err := x.Delete([]byte(fmt.Sprintf("%03d", k)))
178 if err != nil { 178 if err != nil {
179 t.Fatalf("expected nil error, got: %v", err) 179 t.Fatalf("expected nil error, got: %v", err)
180 } 180 }
181 } 181 }
182 } 182 }
183 } 183 }
OLDNEW
« no previous file with comments | « tools/slab/slab.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698