本文整理汇总了Golang中github.com/jenchik/stored/api.StoredMap.AtomicWait方法的典型用法代码示例。如果您正苦于以下问题:Golang StoredMap.AtomicWait方法的具体用法?Golang StoredMap.AtomicWait怎么用?Golang StoredMap.AtomicWait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jenchik/stored/api.StoredMap
的用法示例。
在下文中一共展示了StoredMap.AtomicWait方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BAtomicWaitUpdate
func BAtomicWaitUpdate(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
sm.AtomicWait(func(m api.Mapper) {
m.SetKey(k)
m.Update(k)
})
}
}
示例2: BAtomicWaitFind
func BAtomicWaitFind(b *testing.B, sm api.StoredMap) {
var k string
l := len(UniqKey)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
for i := 0; i < b.N; i++ {
k = UniqKey[i%l]
sm.AtomicWait(func(m api.Mapper) {
if value, found := m.Find(k); found {
_ = value.(string)
}
})
}
}
示例3: BThreadsAtomicWaitUpdate
func BThreadsAtomicWaitUpdate(b *testing.B, sm api.StoredMap) {
l := len(UniqKey)
b.SetParallelism(CntBenchWorks)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var k string
var i int
for pb.Next() {
k = UniqKey[i%l]
sm.AtomicWait(func(m api.Mapper) {
m.SetKey(k)
m.Update(k)
})
i++
}
})
}
示例4: BThreadsAtomicWaitFind
func BThreadsAtomicWaitFind(b *testing.B, sm api.StoredMap) {
l := len(UniqKey)
b.SetParallelism(CntBenchWorks)
b.ReportAllocs()
b.SetBytes(2)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var k string
var i int
for pb.Next() {
k = UniqKey[i%l]
sm.AtomicWait(func(m api.Mapper) {
if value, found := m.Find(k); found {
_ = value.(string)
}
})
i++
}
})
}