MCPcopy Index your code
hub / github.com/aceld/zinx / doSetWithLockCheck

Method doSetWithLockCheck

zutils/shard_lock_map.go:209–220  ·  view source on GitHub ↗

doSetWithLockCheck performs a set operation with lock checking

(key string, val interface{})

Source from the content-addressed store, hash-verified

207
208// doSetWithLockCheck performs a set operation with lock checking
209func (slm ShardLockMaps) doSetWithLockCheck(key string, val interface{}) (interface{}, bool) {
210 shard := slm.GetShard(key)
211 shard.Lock()
212 defer shard.Unlock()
213
214 if got, ok := shard.items[key]; ok {
215 return got, false
216 }
217
218 shard.items[key] = val
219 return val, true
220}
221
222// doSetWithLockCheckWithFunc performs a set operation with function execution inside lock
223func (slm ShardLockMaps) doSetWithLockCheckWithFunc(key string, f func(key string) interface{}) (interface{}, bool) {

Callers 2

GetOrSetMethod · 0.95
GetOrSetFuncMethod · 0.95

Calls 1

GetShardMethod · 0.95

Tested by

no test coverage detected