brew vendor-gems: commit updates.
This commit is contained in:
parent
ddb4229df3
commit
e7980e9fb5
@ -23,7 +23,7 @@ kernel = (class << ::Kernel; self; end)
|
||||
k.send(:private, :require) if private_require
|
||||
end
|
||||
end
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/concurrent-ruby-1.2.0/lib/concurrent-ruby")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/concurrent-ruby-1.2.1/lib/concurrent-ruby")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/i18n-1.12.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/minitest-5.17.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/tzinfo-2.0.6/lib")
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
require 'fiber'
|
||||
require 'concurrent/utility/engine'
|
||||
require 'concurrent/constants'
|
||||
|
||||
@ -9,8 +9,8 @@ module Concurrent
|
||||
# @!visibility private
|
||||
class MriMapBackend < NonConcurrentMapBackend
|
||||
|
||||
def initialize(options = nil)
|
||||
super(options)
|
||||
def initialize(options = nil, &default_proc)
|
||||
super(options, &default_proc)
|
||||
@write_lock = Mutex.new
|
||||
end
|
||||
|
||||
@ -12,8 +12,10 @@ module Concurrent
|
||||
# directly without calling each other. This is important because of the
|
||||
# SynchronizedMapBackend which uses a non-reentrant mutex for performance
|
||||
# reasons.
|
||||
def initialize(options = nil)
|
||||
@backend = {}
|
||||
def initialize(options = nil, &default_proc)
|
||||
validate_options_hash!(options) if options.kind_of?(::Hash)
|
||||
@backend = Hash.new(&default_proc)
|
||||
@default_proc = default_proc
|
||||
end
|
||||
|
||||
def [](key)
|
||||
@ -55,7 +57,7 @@ module Concurrent
|
||||
end
|
||||
|
||||
def compute(key)
|
||||
store_computed_value(key, yield(@backend[key]))
|
||||
store_computed_value(key, yield(get_or_default(key, nil)))
|
||||
end
|
||||
|
||||
def merge_pair(key, value)
|
||||
@ -67,7 +69,7 @@ module Concurrent
|
||||
end
|
||||
|
||||
def get_and_set(key, value)
|
||||
stored_value = @backend[key]
|
||||
stored_value = get_or_default(key, nil)
|
||||
@backend[key] = value
|
||||
stored_value
|
||||
end
|
||||
@ -109,13 +111,11 @@ module Concurrent
|
||||
@backend.fetch(key, default_value)
|
||||
end
|
||||
|
||||
alias_method :_get, :[]
|
||||
alias_method :_set, :[]=
|
||||
private :_get, :_set
|
||||
private
|
||||
|
||||
def initialize_copy(other)
|
||||
super
|
||||
@backend = {}
|
||||
@backend = Hash.new(&@default_proc)
|
||||
self
|
||||
end
|
||||
|
||||
Binary file not shown.
@ -46,6 +46,12 @@ module Concurrent
|
||||
# @note Atomic methods taking a block do not allow the `self` instance
|
||||
# to be used within the block. Doing so will cause a deadlock.
|
||||
|
||||
# @!method []=(key, value)
|
||||
# Set a value with key
|
||||
# @param [Object] key
|
||||
# @param [Object] value
|
||||
# @return [Object] the new value
|
||||
|
||||
# @!method compute_if_absent(key)
|
||||
# Compute and store new value for key if the key is absent.
|
||||
# @param [Object] key
|
||||
@ -119,8 +125,12 @@ module Concurrent
|
||||
# @return [true, false] true if deleted
|
||||
# @!macro map.atomic_method
|
||||
|
||||
#
|
||||
def initialize(options = nil, &block)
|
||||
# NonConcurrentMapBackend handles default_proc natively
|
||||
unless defined?(Collection::NonConcurrentMapBackend) and self < Collection::NonConcurrentMapBackend
|
||||
|
||||
# @param [Hash, nil] options options to set the :initial_capacity or :load_factor. Ignored on some Rubies.
|
||||
# @param [Proc] default_proc Optional block to compute the default value if the key is not set, like `Hash#default_proc`
|
||||
def initialize(options = nil, &default_proc)
|
||||
if options.kind_of?(::Hash)
|
||||
validate_options_hash!(options)
|
||||
else
|
||||
@ -128,7 +138,7 @@ module Concurrent
|
||||
end
|
||||
|
||||
super(options)
|
||||
@default_proc = block
|
||||
@default_proc = default_proc
|
||||
end
|
||||
|
||||
# Get a value with key
|
||||
@ -147,13 +157,6 @@ module Concurrent
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
# Set a value with key
|
||||
# @param [Object] key
|
||||
# @param [Object] value
|
||||
# @return [Object] the new value
|
||||
def []=(key, value)
|
||||
super
|
||||
end
|
||||
|
||||
alias_method :get, :[]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user