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

sync: get the size of sync.Map #20921

Closed
AlexStocks opened this issue Jul 6, 2017 · 2 comments
Closed

sync: get the size of sync.Map #20921

AlexStocks opened this issue Jul 6, 2017 · 2 comments

Comments

@AlexStocks
Copy link

AlexStocks commented Jul 6, 2017

What version of Go are you using (go version)?

go 1.9 beta2

What did you expect to see?

If use map, I can get the size of it by len(map). Whatever, how can I get the size of sync.Map?

What did you see instead?

Add function: func (m *Map) Len() int

Maybe Map should have a member "size int64". Map can change its value in Store & LoadOrStore & Delete by using atomic.AddInt64. And then (m Map) Len() can return m.size to get Map's size.

@ALTree
Copy link
Member

ALTree commented Jul 6, 2017

Thanks for the report.

This is an exact duplicate of #20680 (sync: add Map.Len method?), so I'm closing this thread in favour of the older one.

@ALTree ALTree closed this as completed Jul 6, 2017
@AlexStocks
Copy link
Author

okay

@mikioh mikioh changed the title get the size of sync.Map sync: get the size of sync.Map Jul 10, 2017
@golang golang locked and limited conversation to collaborators Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants