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

Method ClearWithFuncLock

zutils/shard_lock_map.go:284–293  ·  view source on GitHub ↗

ClearWithFuncLock clears all items with a callback function executed under lock. WARNING: Do not perform operations on the container within onClear to avoid deadlocks.

(onClear func(key string, val interface{}))

Source from the content-addressed store, hash-verified

282// ClearWithFuncLock clears all items with a callback function executed under lock.
283// WARNING: Do not perform operations on the container within onClear to avoid deadlocks.
284func (slm ShardLockMaps) ClearWithFuncLock(onClear func(key string, val interface{})) {
285 for _, shard := range slm.shards {
286 shard.Lock()
287 for key, val := range shard.items {
288 onClear(key, val)
289 }
290 shard.items = make(map[string]interface{})
291 shard.Unlock()
292 }
293}
294
295// IsEmpty checks if map is empty.
296func (slm ShardLockMaps) IsEmpty() bool {

Callers 1

TestClearWithFuncLockFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestClearWithFuncLockFunction · 0.76