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{}))
| 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. |
| 284 | func (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. |
| 296 | func (slm ShardLockMaps) IsEmpty() bool { |
no outgoing calls