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{}))
| 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. |
| 246 | func (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. |