MCPcopy
hub / github.com/aceld/zinx / Keys

Method Keys

zutils/shard_lock_map.go:394–419  ·  view source on GitHub ↗

Keys returns all keys as []string

()

Source from the content-addressed store, hash-verified

392
393// Keys returns all keys as []string
394func (slm ShardLockMaps) Keys() []string {
395 count := slm.Count()
396 ch := make(chan string, count)
397 go func() {
398 wg := sync.WaitGroup{}
399 wg.Add(slm.shardCount)
400 for _, shard := range slm.shards {
401 go func(shard *SingleShardMap) {
402 shard.RLock()
403 for key := range shard.items {
404 ch <- key
405 }
406 shard.RUnlock()
407 wg.Done()
408 }(shard)
409 }
410 wg.Wait()
411 close(ch)
412 }()
413
414 keys := make([]string, 0, count)
415 for k := range ch {
416 keys = append(keys, k)
417 }
418 return keys
419}
420
421// IterCb Iterator callback,called for every key,value found in maps.
422// RLock is held for all calls for a given shard

Callers 5

BenchmarkKeysFunction · 0.95
TestKeysFunction · 0.95
TestKeysWhenRemovingFunction · 0.95
GetAllConnIDMethod · 0.80
GetAllConnIdStrMethod · 0.80

Calls 2

CountMethod · 0.95
AddMethod · 0.65

Tested by 3

BenchmarkKeysFunction · 0.76
TestKeysFunction · 0.76
TestKeysWhenRemovingFunction · 0.76