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
What's mean "move the keys and values in memory" ? #14
Comments
Hi @mlkt, Suppose you have this class:
and a map Now you insert values into the map:
What is dangerous is to store a pointer to a value inside the flat_hash_map, as in:
When new values are inserted into the phmap, the value pointed by p is likely to change:
Hope this helps! |
OK, thanks, I see. If so, in a multithreaded environment, after getting a value's reference, the reference may become invalid before read it ? (even if mutex are used) |
yes, unfortunately, you can't rely on internal mutexes for this. |
so in this case, use parallel_node_hash_map ? |
parallel_node_hash_map should be OK for a value reference (unless it is deleted from another thread of course), but iterators would not work reliably. |
OK, Thanks! |
What's mean "move the keys and values in memory" ?
Why "pointer may become invalid"?I can't understand.
Because used memcpy() and didn't use the copy constructor?
The text was updated successfully, but these errors were encountered: