Key-Value-Polyglot icon indicating copy to clipboard operation
Key-Value-Polyglot copied to clipboard

Protect map with a mutex

Open dsymonds opened this issue 12 years ago • 2 comments

Go maps are not safe to mutate concurrent with other mutations or reads.

dsymonds avatar Mar 21 '12 05:03 dsymonds

Thanks! None of the version are thread safe, and I agree they should be. My tests never used more than one thread, so performance results shouldn't change. I'll merge this when I do the other two versions.

grahamking avatar Mar 21 '12 06:03 grahamking

Hah, you beat me to it. Here's another approach that wraps the cache map in a thread-safe container: https://github.com/jbarham/Key-Value-Polyglot/blob/master/memg.go

jbarham avatar Mar 21 '12 06:03 jbarham