lib/roda.rb in roda-2.22.0 vs lib/roda.rb in roda-2.23.0
- old
+ new
@@ -27,9 +27,19 @@
# Make setting value in underlying hash thread safe.
def []=(key, value)
@mutex.synchronize{@hash[key] = value}
end
+
+ private
+
+ # Create a copy of the cache with a separate mutex.
+ def initialize_copy(other)
+ @mutex = Mutex.new
+ other.instance_variable_get(:@mutex).synchronize do
+ @hash = other.instance_variable_get(:@hash).dup
+ end
+ end
end
# Base class used for Roda requests. The instance methods for this
# class are added by Roda::RodaPlugins::Base::RequestMethods, the
# class methods are added by Roda::RodaPlugins::Base::RequestClassMethods.