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
Thread Safety Fix #352
Thread Safety Fix #352
Changes from 2 commits
77a565b
a3a7d0d
649d435
9aabd00
5480dd3
358249b
6d2ec72
3da644f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require 'concurrent/hash' | ||
|
||
require 'i18n/version' | ||
require 'i18n/exceptions' | ||
require 'i18n/interpolate/ruby' | ||
|
@@ -335,7 +337,7 @@ def normalize_key(key, separator) | |
end | ||
|
||
def normalized_key_cache | ||
@normalized_key_cache ||= Hash.new { |h,k| h[k] = {} } | ||
@normalized_key_cache ||= Concurrent::Hash.new { |h,k| h[k] = Concurrent::Hash.new } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While IMO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @romuloceccon Could you please submit a PR to my branch here to fix that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, and sorry for the delay. I'll do it during the weekend. Meanwhile, here's a demonstration of why the code above is not thread safe: https://gist.github.com/romuloceccon/f44a30cb43f8081279a484193d386f55. |
||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we, eventually, not have the version locked down so specifically but instead e.g.
~> 1.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relaxed in 5480dd3.