Replaced ThreadSafe::Map
with successor Concurrent::Map
.
The thread_safe gem is being deprecated and all its code has been merged into the concurrent-ruby gem. The new class, Concurrent::Map, is exactly the same as its predecessor except for fixes to two bugs discovered during the merge.
This commit is contained in:
parent
0c39a022b0
commit
56ac6e4768
@ -122,12 +122,11 @@ PATH
|
||||
activesupport (= 5.0.0.alpha)
|
||||
arel (= 7.0.0.alpha)
|
||||
activesupport (5.0.0.alpha)
|
||||
concurrent-ruby (~> 0.9.1)
|
||||
concurrent-ruby (~> 1.0.0.pre2, < 2.0.0)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
method_source
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
rails (5.0.0.alpha)
|
||||
actionmailer (= 5.0.0.alpha)
|
||||
@ -172,7 +171,7 @@ GEM
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.9.1.1)
|
||||
concurrent-ruby (0.9.1)
|
||||
concurrent-ruby (1.0.0.pre2)
|
||||
connection_pool (2.2.0)
|
||||
dalli (2.7.4)
|
||||
dante (0.2.0)
|
||||
|
@ -1,9 +1,9 @@
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'action_view/path_set'
|
||||
|
||||
module ActionView
|
||||
class DependencyTracker # :nodoc:
|
||||
@trackers = ThreadSafe::Cache.new
|
||||
@trackers = Concurrent::Map.new
|
||||
|
||||
def self.find_dependencies(name, template, view_paths = nil)
|
||||
tracker = @trackers[template.handler]
|
||||
|
@ -1,11 +1,11 @@
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'action_view/dependency_tracker'
|
||||
require 'monitor'
|
||||
|
||||
module ActionView
|
||||
class Digestor
|
||||
cattr_reader(:cache)
|
||||
@@cache = ThreadSafe::Cache.new
|
||||
@@cache = Concurrent::Map.new
|
||||
@@digest_monitor = Monitor.new
|
||||
|
||||
class PerRequestDigestCacheExpiry < Struct.new(:app) # :nodoc:
|
||||
@ -28,7 +28,7 @@ def digest(options)
|
||||
cache_key = ([ options[:name], options[:finder].details_key.hash ].compact + Array.wrap(options[:dependencies])).join('.')
|
||||
|
||||
# this is a correctly done double-checked locking idiom
|
||||
# (ThreadSafe::Cache's lookups have volatile semantics)
|
||||
# (Concurrent::Map's lookups have volatile semantics)
|
||||
@@cache[cache_key] || @@digest_monitor.synchronize do
|
||||
@@cache.fetch(cache_key) do # re-check under lock
|
||||
compute_and_store_digest(cache_key, options)
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'active_support/core_ext/module/remove_method'
|
||||
require 'active_support/core_ext/module/attribute_accessors'
|
||||
require 'action_view/template/resolver'
|
||||
@ -62,7 +62,7 @@ class DetailsKey #:nodoc:
|
||||
alias :object_hash :hash
|
||||
|
||||
attr_reader :hash
|
||||
@details_keys = ThreadSafe::Cache.new
|
||||
@details_keys = Concurrent::Map.new
|
||||
|
||||
def self.get(details)
|
||||
if details[:formats]
|
||||
|
@ -1,5 +1,5 @@
|
||||
require 'action_view/renderer/partial_renderer/collection_caching'
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
|
||||
module ActionView
|
||||
class PartialIteration
|
||||
@ -283,8 +283,8 @@ def iterate! # :nodoc:
|
||||
class PartialRenderer < AbstractRenderer
|
||||
include CollectionCaching
|
||||
|
||||
PREFIXED_PARTIAL_NAMES = ThreadSafe::Cache.new do |h, k|
|
||||
h[k] = ThreadSafe::Cache.new
|
||||
PREFIXED_PARTIAL_NAMES = Concurrent::Map.new do |h, k|
|
||||
h[k] = Concurrent::Map.new
|
||||
end
|
||||
|
||||
def initialize(*)
|
||||
|
@ -3,7 +3,7 @@
|
||||
require "active_support/core_ext/module/attribute_accessors"
|
||||
require "action_view/template"
|
||||
require "thread"
|
||||
require "thread_safe"
|
||||
require "concurrent"
|
||||
|
||||
module ActionView
|
||||
# = Action View Resolver
|
||||
@ -35,7 +35,7 @@ def to_str
|
||||
|
||||
# Threadsafe template cache
|
||||
class Cache #:nodoc:
|
||||
class SmallCache < ThreadSafe::Cache
|
||||
class SmallCache < Concurrent::Map
|
||||
def initialize(options = {})
|
||||
super(options.merge(:initial_capacity => 2))
|
||||
end
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'concurrent'
|
||||
require 'thread_safe'
|
||||
|
||||
module ActiveJob
|
||||
# == Active Job Async Job
|
||||
@ -31,7 +30,7 @@ class AsyncJob
|
||||
fallback_policy: :caller_runs # shouldn't matter -- 0 max queue
|
||||
}.freeze
|
||||
|
||||
QUEUES = ThreadSafe::Cache.new do |hash, queue_name| #:nodoc:
|
||||
QUEUES = Concurrent::Map.new do |hash, queue_name| #:nodoc:
|
||||
hash.compute_if_absent(queue_name) { ActiveJob::AsyncJob.create_thread_pool }
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'mutex_m'
|
||||
|
||||
module ActiveModel
|
||||
@ -350,7 +350,7 @@ def instance_method_already_implemented?(method_name) #:nodoc:
|
||||
# significantly (in our case our test suite finishes 10% faster with
|
||||
# this cache).
|
||||
def attribute_method_matchers_cache #:nodoc:
|
||||
@attribute_method_matchers_cache ||= ThreadSafe::Cache.new(initial_capacity: 4)
|
||||
@attribute_method_matchers_cache ||= Concurrent::Map.new(initial_capacity: 4)
|
||||
end
|
||||
|
||||
def attribute_method_matchers_matching(method_name) #:nodoc:
|
||||
|
@ -1,7 +1,7 @@
|
||||
require 'active_support/core_ext/enumerable'
|
||||
require 'active_support/core_ext/string/filters'
|
||||
require 'mutex_m'
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
|
||||
module ActiveRecord
|
||||
# = Active Record Attribute Methods
|
||||
@ -37,7 +37,7 @@ def self.set_name_cache(name, value)
|
||||
class AttributeMethodCache
|
||||
def initialize
|
||||
@module = Module.new
|
||||
@method_cache = ThreadSafe::Cache.new
|
||||
@method_cache = Concurrent::Map.new
|
||||
end
|
||||
|
||||
def [](name)
|
||||
|
@ -1,5 +1,5 @@
|
||||
require 'thread'
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'monitor'
|
||||
|
||||
module ActiveRecord
|
||||
@ -337,7 +337,7 @@ def initialize(spec)
|
||||
# that case +conn.owner+ attr should be consulted.
|
||||
# Access and modification of +@thread_cached_conns+ does not require
|
||||
# synchronization.
|
||||
@thread_cached_conns = ThreadSafe::Cache.new(:initial_capacity => @size)
|
||||
@thread_cached_conns = Concurrent::Map.new(:initial_capacity => @size)
|
||||
|
||||
@connections = []
|
||||
@automatic_reconnect = true
|
||||
@ -824,11 +824,11 @@ def initialize
|
||||
# These caches are keyed by klass.name, NOT klass. Keying them by klass
|
||||
# alone would lead to memory leaks in development mode as all previous
|
||||
# instances of the class would stay in memory.
|
||||
@owner_to_pool = ThreadSafe::Cache.new(:initial_capacity => 2) do |h,k|
|
||||
h[k] = ThreadSafe::Cache.new(:initial_capacity => 2)
|
||||
@owner_to_pool = Concurrent::Map.new(:initial_capacity => 2) do |h,k|
|
||||
h[k] = Concurrent::Map.new(:initial_capacity => 2)
|
||||
end
|
||||
@class_to_pool = ThreadSafe::Cache.new(:initial_capacity => 2) do |h,k|
|
||||
h[k] = ThreadSafe::Cache.new
|
||||
@class_to_pool = Concurrent::Map.new(:initial_capacity => 2) do |h,k|
|
||||
h[k] = Concurrent::Map.new
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
|
||||
module ActiveRecord
|
||||
module Type
|
||||
class TypeMap # :nodoc:
|
||||
def initialize
|
||||
@mapping = {}
|
||||
@cache = ThreadSafe::Cache.new do |h, key|
|
||||
h.fetch_or_store(key, ThreadSafe::Cache.new)
|
||||
@cache = Concurrent::Map.new do |h, key|
|
||||
h.fetch_or_store(key, Concurrent::Map.new)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
* Replaced deprecated `ThreadSafe::Cache` with its successor `Concurrent::Map` now that
|
||||
the thread_safe gem has been merged into concurrent-ruby.
|
||||
|
||||
*Jerry D'Antonio*
|
||||
|
||||
* Updated Unicode version to 8.0.0
|
||||
|
||||
*Anshul Sharma*
|
||||
|
@ -24,7 +24,6 @@
|
||||
s.add_dependency 'json', '~> 1.7', '>= 1.7.7'
|
||||
s.add_dependency 'tzinfo', '~> 1.1'
|
||||
s.add_dependency 'minitest', '~> 5.1'
|
||||
s.add_dependency 'thread_safe','~> 0.3', '>= 0.3.4'
|
||||
s.add_dependency 'concurrent-ruby', '~> 0.9.1'
|
||||
s.add_dependency 'concurrent-ruby', '~> 1.0.0.pre2', '< 2.0.0'
|
||||
s.add_dependency 'method_source'
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
require 'set'
|
||||
require 'thread'
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'pathname'
|
||||
require 'active_support/core_ext/module/aliasing'
|
||||
require 'active_support/core_ext/module/attribute_accessors'
|
||||
@ -585,7 +585,7 @@ def remove_unloadable_constants!
|
||||
|
||||
class ClassCache
|
||||
def initialize
|
||||
@store = ThreadSafe::Cache.new
|
||||
@store = Concurrent::Map.new
|
||||
end
|
||||
|
||||
def empty?
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'active_support/core_ext/array/prepend_and_append'
|
||||
require 'active_support/i18n'
|
||||
|
||||
@ -25,7 +25,7 @@ module Inflector
|
||||
# singularization rules that is runs. This guarantees that your rules run
|
||||
# before any of the rules that may already have been loaded.
|
||||
class Inflections
|
||||
@__instance__ = ThreadSafe::Cache.new
|
||||
@__instance__ = Concurrent::Map.new
|
||||
|
||||
class Uncountables < Array
|
||||
def initialize
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'openssl'
|
||||
|
||||
module ActiveSupport
|
||||
@ -28,7 +28,7 @@ def generate_key(salt, key_size=64)
|
||||
class CachingKeyGenerator
|
||||
def initialize(key_generator)
|
||||
@key_generator = key_generator
|
||||
@cache_keys = ThreadSafe::Cache.new
|
||||
@cache_keys = Concurrent::Map.new
|
||||
end
|
||||
|
||||
# Returns a derived key suitable for use. The default key_size is chosen
|
||||
|
@ -1,5 +1,5 @@
|
||||
require 'mutex_m'
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
|
||||
module ActiveSupport
|
||||
module Notifications
|
||||
@ -12,7 +12,7 @@ class Fanout
|
||||
|
||||
def initialize
|
||||
@subscribers = []
|
||||
@listeners_for = ThreadSafe::Cache.new
|
||||
@listeners_for = Concurrent::Map.new
|
||||
super
|
||||
end
|
||||
|
||||
@ -51,7 +51,7 @@ def publish(name, *args)
|
||||
end
|
||||
|
||||
def listeners_for(name)
|
||||
# this is correctly done double-checked locking (ThreadSafe::Cache's lookups have volatile semantics)
|
||||
# this is correctly done double-checked locking (Concurrent::Map's lookups have volatile semantics)
|
||||
@listeners_for[name] || synchronize do
|
||||
# use synchronisation when accessing @subscribers
|
||||
@listeners_for[name] ||= @subscribers.select { |s| s.subscribed_to?(name) }
|
||||
|
@ -1,5 +1,5 @@
|
||||
require 'tzinfo'
|
||||
require 'thread_safe'
|
||||
require 'concurrent'
|
||||
require 'active_support/core_ext/object/blank'
|
||||
require 'active_support/core_ext/object/try'
|
||||
|
||||
@ -189,7 +189,7 @@ class TimeZone
|
||||
UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
|
||||
UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.tr(':', '')
|
||||
|
||||
@lazy_zones_map = ThreadSafe::Cache.new
|
||||
@lazy_zones_map = Concurrent::Map.new
|
||||
|
||||
class << self
|
||||
# Assumes self represents an offset from UTC in seconds (as returned from
|
||||
|
Loading…
Reference in New Issue
Block a user