MCPcopy Create free account
hub / github.com/Super-long/ChubbyGo / IterCb

Method IterCb

BaseServer/concurrentHashMap.go:275–284  ·  view source on GitHub ↗

Callback based iterator, cheapest way to read all elements in a map. 传入一个回调函数,目前map中的每个值都会调用这个回调

(fn IterCb)

Source from the content-addressed store, hash-verified

273// all elements in a map.
274// 传入一个回调函数,目前map中的每个值都会调用这个回调
275func (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阻塞

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected