Callback based iterator, cheapest way to read all elements in a map. 传入一个回调函数,目前map中的每个值都会调用这个回调
(fn IterCb)
| 273 | // all elements in a map. |
| 274 | // 传入一个回调函数,目前map中的每个值都会调用这个回调 |
| 275 | func (m ConcurrentHashMap) IterCb(fn IterCb) { |
| 276 | for idx := range m.ThreadSafeHashMap { |
| 277 | shard := (m.ThreadSafeHashMap)[idx] |
| 278 | shard.RLock() |
| 279 | for key, value := range shard.items { |
| 280 | fn(key, value) |
| 281 | } |
| 282 | shard.RUnlock() |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | // Return all keys as []string |
| 287 | // 这个貌似不对 可能channel会阻塞,因为count结束以后可能会传入值,导致这里channel阻塞 |
nothing calls this directly
no outgoing calls
no test coverage detected