Skip to content

Commit

Permalink
Merge pull request #105 from dreson4/master
Browse files Browse the repository at this point in the history
panic when accessing map elements before initializing
  • Loading branch information
orcaman committed Dec 22, 2021
2 parents 44dafcb + bcccab1 commit 893feb2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions concurrent_map.go
Expand Up @@ -198,6 +198,10 @@ func (m ConcurrentMap) Clear() {
// It returns once the size of each buffered channel is determined,
// before all the channels are populated using goroutines.
func snapshot(m ConcurrentMap) (chans []chan Tuple) {
//When you access map items before initializing.
if len(m) == 0{
panic(`cmap.ConcurrentMap is not initialized. Should run New() before usage.`)
}
chans = make([]chan Tuple, SHARD_COUNT)
wg := sync.WaitGroup{}
wg.Add(SHARD_COUNT)
Expand Down

0 comments on commit 893feb2

Please sign in to comment.