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

Method LockFuncWithKey

zutils/shard_lock_map.go:246–251  ·  view source on GitHub ↗

LockFuncWithKey executes a function with write lock on the shard containing the key. WARNING: Do not perform operations on the container within f to avoid deadlocks.

(key string, f func(shardData map[string]interface{}))

Source from the content-addressed store, hash-verified

244// LockFuncWithKey executes a function with write lock on the shard containing the key.
245// WARNING: Do not perform operations on the container within f to avoid deadlocks.
246func (slm ShardLockMaps) LockFuncWithKey(key string, f func(shardData map[string]interface{})) {
247 shard := slm.GetShard(key)
248 shard.Lock()
249 defer shard.Unlock()
250 f(shard.items)
251}
252
253// RLockFuncWithKey executes a function with read lock on the shard containing the key.
254// WARNING: Do not perform write operations on the container within f to avoid deadlocks.

Callers 1

TestLockFuncWithKeyFunction · 0.95

Calls 1

GetShardMethod · 0.95

Tested by 1

TestLockFuncWithKeyFunction · 0.76