Closed FranklinYu closed 8 years ago
None of the core data structures in Ruby are thread safe, but as long as you don’t modify the internal state of the instance after creation then I believe that it is safe. I have only used it under MRI (Where we have a GIL)
You are welcome to verify this using JRuby if you want :)
Yes, I also believe it safe if I do not modify it; but I would like to know, in your implementation, whether the four method you provide will modify it. So it is not about my usage, but about the detailed implementation; sure I can check myself by reading the implementation line by line, but I would appreciate it if you know it.
I believe that they are safe, but it was a long time since I wrote the code so you’ll better check for yourself. I’m closing this issue now, but you are welcome to open it again if you find an issue.
It is not mentioned in README. For example, if I initialize a
hashids
instance at startup, and have several concurrent threads encoding and decoding with the instance, would there be race condition? In other words, will the#encode
,#decode
,#encode_hex
and#decode_hex
modify thehashids
instance?