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

Method RemoveCb

zutils/shard_lock_map.go:155–166  ·  view source on GitHub ↗

RemoveCb locks the shard containing the key, retrieves its current value and calls the callback with those params If callback returns true and element exists, it will remove it from the map Returns the value returned by the callback (even if element was not present in the map)

(key string, cb RemoveCb)

Source from the content-addressed store, hash-verified

153// If callback returns true and element exists, it will remove it from the map
154// Returns the value returned by the callback (even if element was not present in the map)
155func (slm ShardLockMaps) RemoveCb(key string, cb RemoveCb) bool {
156
157 shard := slm.GetShard(key)
158 shard.Lock()
159 v, ok := shard.items[key]
160 remove := cb(key, v, ok)
161 if remove && ok {
162 delete(shard.items, key)
163 }
164 shard.Unlock()
165 return remove
166}
167
168// Pop removes an element from the map and returns it
169func (slm ShardLockMaps) Pop(key string) (v interface{}, exists bool) {

Callers 1

TestRemoveCbFunction · 0.95

Calls 1

GetShardMethod · 0.95

Tested by 1

TestRemoveCbFunction · 0.76