Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is ConcurrentMap sometimes passed by value and sometimes by reference? #14

Closed
taybin opened this issue Feb 29, 2016 · 1 comment
Closed

Comments

@taybin
Copy link

taybin commented Feb 29, 2016

Why is ConcurrentMap sometimes passed by value and sometimes by reference?

// Returns shard under given key
func (m ConcurrentMap) GetShard(key <KEY>) *ConcurrentMapShared {
    hasher := fnv.New32()
    hasher.Write([]byte(key))
    return m[int(hasher.Sum32())%SHARD_COUNT]
}

// Sets the given value under the specified key.
func (m *ConcurrentMap) Set(key <KEY>, value <VAL>) {
    // Get map shard.
    shard := m.GetShard(key)
    shard.Lock()
    defer shard.Unlock()
    shard.items[key] = value
}
@orcaman
Copy link
Owner

orcaman commented Dec 11, 2016

No good reason really. Your'e welcome to send a PR to fix this :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants