Merge pull request #8258 from Homebrew/dependabot/bundler/Library/Homebrew/concurrent-ruby-1.1.7
build(deps): bump concurrent-ruby from 1.1.6 to 1.1.7 in /Library/Homebrew
This commit is contained in:
commit
e72275eafd
@ -18,7 +18,7 @@ GEM
|
|||||||
colorize (0.8.1)
|
colorize (0.8.1)
|
||||||
commander (4.5.2)
|
commander (4.5.2)
|
||||||
highline (~> 2.0.0)
|
highline (~> 2.0.0)
|
||||||
concurrent-ruby (1.1.6)
|
concurrent-ruby (1.1.7)
|
||||||
connection_pool (2.2.3)
|
connection_pool (2.2.3)
|
||||||
diff-lcs (1.4.4)
|
diff-lcs (1.4.4)
|
||||||
docile (1.3.2)
|
docile (1.3.2)
|
||||||
|
|||||||
23
Library/Homebrew/vendor/bundle/bundler/setup.rb
vendored
23
Library/Homebrew/vendor/bundle/bundler/setup.rb
vendored
@ -3,7 +3,7 @@ require 'rbconfig'
|
|||||||
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
||||||
ruby_version = RbConfig::CONFIG["ruby_version"]
|
ruby_version = RbConfig::CONFIG["ruby_version"]
|
||||||
path = File.expand_path('..', __FILE__)
|
path = File.expand_path('..', __FILE__)
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/concurrent-ruby-1.1.7/lib/concurrent-ruby"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.8.5/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.8.5/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/minitest-5.14.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/minitest-5.14.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thread_safe-0.3.6/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thread_safe-0.3.6/lib"
|
||||||
@ -21,7 +21,10 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/json-2.3.1/lib"
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/docile-1.3.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/docile-1.3.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-0.18.5/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-0.18.5/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/codecov-0.2.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/codecov-0.2.5/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/coderay-1.1.3/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/highline-2.0.3/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/commander-4.5.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/connection_pool-2.2.3/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/connection_pool-2.2.3/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/diff-lcs-1.4.4/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/diff-lcs-1.4.4/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/unf_ext-0.0.7.7"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/unf_ext-0.0.7.7"
|
||||||
@ -42,13 +45,17 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/nokogiri-1.10.10/lib"
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ntlm-http-0.1.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ntlm-http-0.1.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/webrobots-0.1.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/webrobots-0.1.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mechanize-2.7.6/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mechanize-2.7.6/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/method_source-1.0.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mustache-1.1.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mustache-1.1.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.19.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.19.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-3.0.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-3.1.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.7.1.4/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.7.1.4/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/patchelf-1.1.1/lib"
|
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib"
|
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.0.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.0.0/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-0.5.5823/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parlour-4.0.1/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/patchelf-1.2.0/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/pry-0.13.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/rdiscount-2.2.0.1"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/rdiscount-2.2.0.1"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rdiscount-2.2.0.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rdiscount-2.2.0.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/regexp_parser-1.7.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/regexp_parser-1.7.1/lib"
|
||||||
@ -62,10 +69,14 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-3.9.0/lib"
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-its-1.3.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-its-1.3.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-retry-0.6.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-retry-0.6.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-wait-0.0.9/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-wait-0.0.9/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-0.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-0.3.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.7.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.7.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.88.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.88.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.7.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.7.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.42.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.42.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-static-0.5.5823-universal-darwin-19/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-0.5.5823/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thor-1.0.1/lib"
|
||||||
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tapioca-0.4.1/lib"
|
||||||
|
|||||||
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
module Concurrent
|
|
||||||
VERSION = '1.1.6'
|
|
||||||
end
|
|
||||||
@ -16,7 +16,7 @@ module Concurrent
|
|||||||
# operation therefore when two `+=` operations are executed concurrently updates
|
# operation therefore when two `+=` operations are executed concurrently updates
|
||||||
# may be lost. Use `#concat` instead.
|
# may be lost. Use `#concat` instead.
|
||||||
#
|
#
|
||||||
# @see http://ruby-doc.org/core-2.2.0/Array.html Ruby standard library `Array`
|
# @see http://ruby-doc.org/core/Array.html Ruby standard library `Array`
|
||||||
|
|
||||||
# @!macro internal_implementation_note
|
# @!macro internal_implementation_note
|
||||||
ArrayImplementation = case
|
ArrayImplementation = case
|
||||||
@ -58,26 +58,6 @@ module Concurrent
|
|||||||
# end
|
# end
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
# When defining a constructor it is critical that the first line be a call to
|
|
||||||
# `super` with no arguments. The `super` method initializes the background
|
|
||||||
# thread and other asynchronous components.
|
|
||||||
#
|
|
||||||
# ```
|
|
||||||
# class BackgroundLogger
|
|
||||||
# include Concurrent::Async
|
|
||||||
#
|
|
||||||
# def initialize(level)
|
|
||||||
# super()
|
|
||||||
# @logger = Logger.new(STDOUT)
|
|
||||||
# @logger.level = level
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def info(msg)
|
|
||||||
# @logger.info(msg)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# ```
|
|
||||||
#
|
|
||||||
# Mixing this module into a class provides each object two proxy methods:
|
# Mixing this module into a class provides each object two proxy methods:
|
||||||
# `async` and `await`. These methods are thread safe with respect to the
|
# `async` and `await`. These methods are thread safe with respect to the
|
||||||
# enclosing object. The former proxy allows methods to be called
|
# enclosing object. The former proxy allows methods to be called
|
||||||
@ -309,6 +289,7 @@ module Concurrent
|
|||||||
@delegate = delegate
|
@delegate = delegate
|
||||||
@queue = []
|
@queue = []
|
||||||
@executor = Concurrent.global_io_executor
|
@executor = Concurrent.global_io_executor
|
||||||
|
@ruby_pid = $$
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delegates method calls to the wrapped object.
|
# Delegates method calls to the wrapped object.
|
||||||
@ -326,6 +307,7 @@ module Concurrent
|
|||||||
|
|
||||||
ivar = Concurrent::IVar.new
|
ivar = Concurrent::IVar.new
|
||||||
synchronize do
|
synchronize do
|
||||||
|
reset_if_forked
|
||||||
@queue.push [ivar, method, args, block]
|
@queue.push [ivar, method, args, block]
|
||||||
@executor.post { perform } if @queue.length == 1
|
@executor.post { perform } if @queue.length == 1
|
||||||
end
|
end
|
||||||
@ -361,6 +343,13 @@ module Concurrent
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset_if_forked
|
||||||
|
if $$ != @ruby_pid
|
||||||
|
@queue.clear
|
||||||
|
@ruby_pid = $$
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
private_constant :AsyncDelegator
|
private_constant :AsyncDelegator
|
||||||
|
|
||||||
@ -28,38 +28,27 @@ module Concurrent
|
|||||||
# But when a Thread is GC'd, we need to drop the reference to its thread-local
|
# But when a Thread is GC'd, we need to drop the reference to its thread-local
|
||||||
# array, so we don't leak memory
|
# array, so we don't leak memory
|
||||||
|
|
||||||
# @!visibility private
|
FREE = []
|
||||||
FREE = []
|
LOCK = Mutex.new
|
||||||
LOCK = Mutex.new
|
THREAD_LOCAL_ARRAYS = {} # used as a hash set
|
||||||
ARRAYS = {} # used as a hash set
|
|
||||||
# noinspection RubyClassVariableUsageInspection
|
# synchronize when not on MRI
|
||||||
@@next = 0
|
# on MRI using lock in finalizer leads to "can't be called from trap context" error
|
||||||
QUEUE = Queue.new
|
# so the code is carefully written to be tread-safe on MRI relying on GIL
|
||||||
THREAD = Thread.new do
|
|
||||||
while true
|
if Concurrent.on_cruby?
|
||||||
method, i = QUEUE.pop
|
# @!visibility private
|
||||||
case method
|
def self.semi_sync(&block)
|
||||||
when :thread_local_finalizer
|
block.call
|
||||||
LOCK.synchronize do
|
end
|
||||||
FREE.push(i)
|
else
|
||||||
# The cost of GC'ing a TLV is linear in the number of threads using TLVs
|
# @!visibility private
|
||||||
# But that is natural! More threads means more storage is used per TLV
|
def self.semi_sync(&block)
|
||||||
# So naturally more CPU time is required to free more storage
|
LOCK.synchronize(&block)
|
||||||
ARRAYS.each_value do |array|
|
|
||||||
array[i] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
when :thread_finalizer
|
|
||||||
LOCK.synchronize do
|
|
||||||
# The thread which used this thread-local array is now gone
|
|
||||||
# So don't hold onto a reference to the array (thus blocking GC)
|
|
||||||
ARRAYS.delete(i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private_constant :FREE, :LOCK, :ARRAYS, :QUEUE, :THREAD
|
private_constant :FREE, :LOCK, :THREAD_LOCAL_ARRAYS
|
||||||
|
|
||||||
# @!macro thread_local_var_method_get
|
# @!macro thread_local_var_method_get
|
||||||
def value
|
def value
|
||||||
@ -85,7 +74,7 @@ module Concurrent
|
|||||||
# Using Ruby's built-in thread-local storage is faster
|
# Using Ruby's built-in thread-local storage is faster
|
||||||
unless (array = get_threadlocal_array(me))
|
unless (array = get_threadlocal_array(me))
|
||||||
array = set_threadlocal_array([], me)
|
array = set_threadlocal_array([], me)
|
||||||
LOCK.synchronize { ARRAYS[array.object_id] = array }
|
self.class.semi_sync { THREAD_LOCAL_ARRAYS[array.object_id] = array }
|
||||||
ObjectSpace.define_finalizer(me, self.class.thread_finalizer(array.object_id))
|
ObjectSpace.define_finalizer(me, self.class.thread_finalizer(array.object_id))
|
||||||
end
|
end
|
||||||
array[@index] = (value.nil? ? NULL : value)
|
array[@index] = (value.nil? ? NULL : value)
|
||||||
@ -95,32 +84,50 @@ module Concurrent
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
# @!visibility private
|
# @!visibility private
|
||||||
# noinspection RubyClassVariableUsageInspection
|
|
||||||
def allocate_storage
|
def allocate_storage
|
||||||
@index = LOCK.synchronize do
|
@index = FREE.pop || next_index
|
||||||
FREE.pop || begin
|
|
||||||
result = @@next
|
|
||||||
@@next += 1
|
|
||||||
result
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ObjectSpace.define_finalizer(self, self.class.thread_local_finalizer(@index))
|
ObjectSpace.define_finalizer(self, self.class.thread_local_finalizer(@index))
|
||||||
end
|
end
|
||||||
|
|
||||||
# @!visibility private
|
# @!visibility private
|
||||||
def self.thread_local_finalizer(index)
|
def self.thread_local_finalizer(index)
|
||||||
# avoid error: can't be called from trap context
|
proc do
|
||||||
proc { QUEUE.push [:thread_local_finalizer, index] }
|
semi_sync do
|
||||||
|
# The cost of GC'ing a TLV is linear in the number of threads using TLVs
|
||||||
|
# But that is natural! More threads means more storage is used per TLV
|
||||||
|
# So naturally more CPU time is required to free more storage
|
||||||
|
THREAD_LOCAL_ARRAYS.each_value { |array| array[index] = nil }
|
||||||
|
# free index has to be published after the arrays are cleared
|
||||||
|
FREE.push(index)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# @!visibility private
|
# @!visibility private
|
||||||
def self.thread_finalizer(id)
|
def self.thread_finalizer(id)
|
||||||
# avoid error: can't be called from trap context
|
proc do
|
||||||
proc { QUEUE.push [:thread_finalizer, id] }
|
semi_sync do
|
||||||
|
# The thread which used this thread-local array is now gone
|
||||||
|
# So don't hold onto a reference to the array (thus blocking GC)
|
||||||
|
THREAD_LOCAL_ARRAYS.delete(id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# noinspection RubyClassVariableUsageInspection
|
||||||
|
@@next = 0
|
||||||
|
# noinspection RubyClassVariableUsageInspection
|
||||||
|
def next_index
|
||||||
|
LOCK.synchronize do
|
||||||
|
result = @@next
|
||||||
|
@@next += 1
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if Thread.instance_methods.include?(:thread_variable_get)
|
if Thread.instance_methods.include?(:thread_variable_get)
|
||||||
|
|
||||||
def get_threadlocal_array(thread = Thread.current)
|
def get_threadlocal_array(thread = Thread.current)
|
||||||
@ -19,7 +19,7 @@ module Concurrent
|
|||||||
end
|
end
|
||||||
|
|
||||||
def compute_if_absent(key)
|
def compute_if_absent(key)
|
||||||
if stored_value = _get(key) # fast non-blocking path for the most likely case
|
if NULL != (stored_value = @backend.fetch(key, NULL)) # fast non-blocking path for the most likely case
|
||||||
stored_value
|
stored_value
|
||||||
else
|
else
|
||||||
@write_lock.synchronize { super }
|
@write_lock.synchronize { super }
|
||||||
Binary file not shown.
@ -16,6 +16,9 @@ module Concurrent
|
|||||||
# Default maximum number of seconds a thread in the pool may remain idle
|
# Default maximum number of seconds a thread in the pool may remain idle
|
||||||
# before being reclaimed.
|
# before being reclaimed.
|
||||||
|
|
||||||
|
# @!macro thread_pool_executor_constant_default_synchronous
|
||||||
|
# Default value of the :synchronous option.
|
||||||
|
|
||||||
# @!macro thread_pool_executor_attr_reader_max_length
|
# @!macro thread_pool_executor_attr_reader_max_length
|
||||||
# The maximum number of threads that may be created in the pool.
|
# The maximum number of threads that may be created in the pool.
|
||||||
# @return [Integer] The maximum number of threads that may be created in the pool.
|
# @return [Integer] The maximum number of threads that may be created in the pool.
|
||||||
@ -40,6 +43,10 @@ module Concurrent
|
|||||||
# The number of seconds that a thread may be idle before being reclaimed.
|
# The number of seconds that a thread may be idle before being reclaimed.
|
||||||
# @return [Integer] The number of seconds that a thread may be idle before being reclaimed.
|
# @return [Integer] The number of seconds that a thread may be idle before being reclaimed.
|
||||||
|
|
||||||
|
# @!macro thread_pool_executor_attr_reader_synchronous
|
||||||
|
# Whether or not a value of 0 for :max_queue option means the queue must perform direct hand-off or rather unbounded queue.
|
||||||
|
# @return [true, false]
|
||||||
|
|
||||||
# @!macro thread_pool_executor_attr_reader_max_queue
|
# @!macro thread_pool_executor_attr_reader_max_queue
|
||||||
# The maximum number of tasks that may be waiting in the work queue at any one time.
|
# The maximum number of tasks that may be waiting in the work queue at any one time.
|
||||||
# When the queue size reaches `max_queue` subsequent tasks will be rejected in
|
# When the queue size reaches `max_queue` subsequent tasks will be rejected in
|
||||||
@ -21,12 +21,18 @@ if Concurrent.on_jruby?
|
|||||||
# @!macro thread_pool_executor_constant_default_thread_timeout
|
# @!macro thread_pool_executor_constant_default_thread_timeout
|
||||||
DEFAULT_THREAD_IDLETIMEOUT = 60
|
DEFAULT_THREAD_IDLETIMEOUT = 60
|
||||||
|
|
||||||
|
# @!macro thread_pool_executor_constant_default_synchronous
|
||||||
|
DEFAULT_SYNCHRONOUS = false
|
||||||
|
|
||||||
# @!macro thread_pool_executor_attr_reader_max_length
|
# @!macro thread_pool_executor_attr_reader_max_length
|
||||||
attr_reader :max_length
|
attr_reader :max_length
|
||||||
|
|
||||||
# @!macro thread_pool_executor_attr_reader_max_queue
|
# @!macro thread_pool_executor_attr_reader_max_queue
|
||||||
attr_reader :max_queue
|
attr_reader :max_queue
|
||||||
|
|
||||||
|
# @!macro thread_pool_executor_attr_reader_synchronous
|
||||||
|
attr_reader :synchronous
|
||||||
|
|
||||||
# @!macro thread_pool_executor_method_initialize
|
# @!macro thread_pool_executor_method_initialize
|
||||||
def initialize(opts = {})
|
def initialize(opts = {})
|
||||||
super(opts)
|
super(opts)
|
||||||
@ -94,8 +100,10 @@ if Concurrent.on_jruby?
|
|||||||
max_length = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
|
max_length = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
|
||||||
idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
|
idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
|
||||||
@max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
|
@max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
|
||||||
|
@synchronous = opts.fetch(:synchronous, DEFAULT_SYNCHRONOUS)
|
||||||
@fallback_policy = opts.fetch(:fallback_policy, :abort)
|
@fallback_policy = opts.fetch(:fallback_policy, :abort)
|
||||||
|
|
||||||
|
raise ArgumentError.new("`synchronous` cannot be set unless `max_queue` is 0") if @synchronous && @max_queue > 0
|
||||||
raise ArgumentError.new("`max_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if max_length < DEFAULT_MIN_POOL_SIZE
|
raise ArgumentError.new("`max_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if max_length < DEFAULT_MIN_POOL_SIZE
|
||||||
raise ArgumentError.new("`max_threads` cannot be greater than #{DEFAULT_MAX_POOL_SIZE}") if max_length > DEFAULT_MAX_POOL_SIZE
|
raise ArgumentError.new("`max_threads` cannot be greater than #{DEFAULT_MAX_POOL_SIZE}") if max_length > DEFAULT_MAX_POOL_SIZE
|
||||||
raise ArgumentError.new("`min_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if min_length < DEFAULT_MIN_POOL_SIZE
|
raise ArgumentError.new("`min_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if min_length < DEFAULT_MIN_POOL_SIZE
|
||||||
@ -103,7 +111,11 @@ if Concurrent.on_jruby?
|
|||||||
raise ArgumentError.new("#{fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICY_CLASSES.include?(@fallback_policy)
|
raise ArgumentError.new("#{fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICY_CLASSES.include?(@fallback_policy)
|
||||||
|
|
||||||
if @max_queue == 0
|
if @max_queue == 0
|
||||||
queue = java.util.concurrent.LinkedBlockingQueue.new
|
if @synchronous
|
||||||
|
queue = java.util.concurrent.SynchronousQueue.new
|
||||||
|
else
|
||||||
|
queue = java.util.concurrent.LinkedBlockingQueue.new
|
||||||
|
end
|
||||||
else
|
else
|
||||||
queue = java.util.concurrent.LinkedBlockingQueue.new(@max_queue)
|
queue = java.util.concurrent.LinkedBlockingQueue.new(@max_queue)
|
||||||
end
|
end
|
||||||
@ -23,6 +23,9 @@ module Concurrent
|
|||||||
# @!macro thread_pool_executor_constant_default_thread_timeout
|
# @!macro thread_pool_executor_constant_default_thread_timeout
|
||||||
DEFAULT_THREAD_IDLETIMEOUT = 60
|
DEFAULT_THREAD_IDLETIMEOUT = 60
|
||||||
|
|
||||||
|
# @!macro thread_pool_executor_constant_default_synchronous
|
||||||
|
DEFAULT_SYNCHRONOUS = false
|
||||||
|
|
||||||
# @!macro thread_pool_executor_attr_reader_max_length
|
# @!macro thread_pool_executor_attr_reader_max_length
|
||||||
attr_reader :max_length
|
attr_reader :max_length
|
||||||
|
|
||||||
@ -35,6 +38,9 @@ module Concurrent
|
|||||||
# @!macro thread_pool_executor_attr_reader_max_queue
|
# @!macro thread_pool_executor_attr_reader_max_queue
|
||||||
attr_reader :max_queue
|
attr_reader :max_queue
|
||||||
|
|
||||||
|
# @!macro thread_pool_executor_attr_reader_synchronous
|
||||||
|
attr_reader :synchronous
|
||||||
|
|
||||||
# @!macro thread_pool_executor_method_initialize
|
# @!macro thread_pool_executor_method_initialize
|
||||||
def initialize(opts = {})
|
def initialize(opts = {})
|
||||||
super(opts)
|
super(opts)
|
||||||
@ -114,9 +120,11 @@ module Concurrent
|
|||||||
@max_length = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
|
@max_length = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
|
||||||
@idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
|
@idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
|
||||||
@max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
|
@max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
|
||||||
|
@synchronous = opts.fetch(:synchronous, DEFAULT_SYNCHRONOUS)
|
||||||
@fallback_policy = opts.fetch(:fallback_policy, :abort)
|
@fallback_policy = opts.fetch(:fallback_policy, :abort)
|
||||||
raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.include?(@fallback_policy)
|
|
||||||
|
|
||||||
|
raise ArgumentError.new("`synchronous` cannot be set unless `max_queue` is 0") if @synchronous && @max_queue > 0
|
||||||
|
raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.include?(@fallback_policy)
|
||||||
raise ArgumentError.new("`max_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if @max_length < DEFAULT_MIN_POOL_SIZE
|
raise ArgumentError.new("`max_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if @max_length < DEFAULT_MIN_POOL_SIZE
|
||||||
raise ArgumentError.new("`max_threads` cannot be greater than #{DEFAULT_MAX_POOL_SIZE}") if @max_length > DEFAULT_MAX_POOL_SIZE
|
raise ArgumentError.new("`max_threads` cannot be greater than #{DEFAULT_MAX_POOL_SIZE}") if @max_length > DEFAULT_MAX_POOL_SIZE
|
||||||
raise ArgumentError.new("`min_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if @min_length < DEFAULT_MIN_POOL_SIZE
|
raise ArgumentError.new("`min_threads` cannot be less than #{DEFAULT_MIN_POOL_SIZE}") if @min_length < DEFAULT_MIN_POOL_SIZE
|
||||||
@ -201,6 +209,8 @@ module Concurrent
|
|||||||
#
|
#
|
||||||
# @!visibility private
|
# @!visibility private
|
||||||
def ns_enqueue(*args, &task)
|
def ns_enqueue(*args, &task)
|
||||||
|
return false if @synchronous
|
||||||
|
|
||||||
if !ns_limited_queue? || @queue.size < @max_queue
|
if !ns_limited_queue? || @queue.size < @max_queue
|
||||||
@queue << [task, args]
|
@queue << [task, args]
|
||||||
true
|
true
|
||||||
@ -73,7 +73,8 @@ module Concurrent
|
|||||||
# @option opts [Symbol] :fallback_policy (:abort) the policy for handling new
|
# @option opts [Symbol] :fallback_policy (:abort) the policy for handling new
|
||||||
# tasks that are received when the queue size has reached
|
# tasks that are received when the queue size has reached
|
||||||
# `max_queue` or the executor has shut down
|
# `max_queue` or the executor has shut down
|
||||||
#
|
# @option opts [Boolean] :synchronous (DEFAULT_SYNCHRONOUS) whether or not a value of 0
|
||||||
|
# for :max_queue means the queue must perform direct hand-off rather than unbounded.
|
||||||
# @raise [ArgumentError] if `:max_threads` is less than one
|
# @raise [ArgumentError] if `:max_threads` is less than one
|
||||||
# @raise [ArgumentError] if `:min_threads` is less than zero
|
# @raise [ArgumentError] if `:min_threads` is less than zero
|
||||||
# @raise [ArgumentError] if `:fallback_policy` is not one of the values specified
|
# @raise [ArgumentError] if `:fallback_policy` is not one of the values specified
|
||||||
@ -10,7 +10,7 @@ module Concurrent
|
|||||||
# or writing at a time. This includes iteration methods like `#each`,
|
# or writing at a time. This includes iteration methods like `#each`,
|
||||||
# which takes the lock repeatedly when reading an item.
|
# which takes the lock repeatedly when reading an item.
|
||||||
#
|
#
|
||||||
# @see http://ruby-doc.org/core-2.2.0/Hash.html Ruby standard library `Hash`
|
# @see http://ruby-doc.org/core/Hash.html Ruby standard library `Hash`
|
||||||
|
|
||||||
# @!macro internal_implementation_note
|
# @!macro internal_implementation_note
|
||||||
HashImplementation = case
|
HashImplementation = case
|
||||||
@ -5,7 +5,7 @@ module Concurrent
|
|||||||
|
|
||||||
# A thread-safe, immutable variation of Ruby's standard `Struct`.
|
# A thread-safe, immutable variation of Ruby's standard `Struct`.
|
||||||
#
|
#
|
||||||
# @see http://ruby-doc.org/core-2.2.0/Struct.html Ruby standard library `Struct`
|
# @see http://ruby-doc.org/core/Struct.html Ruby standard library `Struct`
|
||||||
module ImmutableStruct
|
module ImmutableStruct
|
||||||
include Synchronization::AbstractStruct
|
include Synchronization::AbstractStruct
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ module Concurrent
|
|||||||
# An thread-safe variation of Ruby's standard `Struct`. Values can be set at
|
# An thread-safe variation of Ruby's standard `Struct`. Values can be set at
|
||||||
# construction or safely changed at any time during the object's lifecycle.
|
# construction or safely changed at any time during the object's lifecycle.
|
||||||
#
|
#
|
||||||
# @see http://ruby-doc.org/core-2.2.0/Struct.html Ruby standard library `Struct`
|
# @see http://ruby-doc.org/core/Struct.html Ruby standard library `Struct`
|
||||||
module MutableStruct
|
module MutableStruct
|
||||||
include Synchronization::AbstractStruct
|
include Synchronization::AbstractStruct
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ module Concurrent
|
|||||||
# struct. Unset parameters default to nil. Passing more parameters than number of attributes
|
# struct. Unset parameters default to nil. Passing more parameters than number of attributes
|
||||||
# will raise an `ArgumentError`.
|
# will raise an `ArgumentError`.
|
||||||
#
|
#
|
||||||
# @see http://ruby-doc.org/core-2.2.0/Struct.html#method-c-new Ruby standard library `Struct#new`
|
# @see http://ruby-doc.org/core/Struct.html#method-c-new Ruby standard library `Struct#new`
|
||||||
|
|
||||||
# @!macro struct_values
|
# @!macro struct_values
|
||||||
#
|
#
|
||||||
@ -9,7 +9,7 @@ module Concurrent
|
|||||||
# or any time thereafter. Attempting to assign a value to a member
|
# or any time thereafter. Attempting to assign a value to a member
|
||||||
# that has already been set will result in a `Concurrent::ImmutabilityError`.
|
# that has already been set will result in a `Concurrent::ImmutabilityError`.
|
||||||
#
|
#
|
||||||
# @see http://ruby-doc.org/core-2.2.0/Struct.html Ruby standard library `Struct`
|
# @see http://ruby-doc.org/core/Struct.html Ruby standard library `Struct`
|
||||||
# @see http://en.wikipedia.org/wiki/Final_(Java) Java `final` keyword
|
# @see http://en.wikipedia.org/wiki/Final_(Java) Java `final` keyword
|
||||||
module SettableStruct
|
module SettableStruct
|
||||||
include Synchronization::AbstractStruct
|
include Synchronization::AbstractStruct
|
||||||
@ -26,8 +26,8 @@ module Concurrent
|
|||||||
# the classes using it. Use {Synchronization::Object} not this abstract class.
|
# the classes using it. Use {Synchronization::Object} not this abstract class.
|
||||||
#
|
#
|
||||||
# @note this object does not support usage together with
|
# @note this object does not support usage together with
|
||||||
# [`Thread#wakeup`](http://ruby-doc.org/core-2.2.0/Thread.html#method-i-wakeup)
|
# [`Thread#wakeup`](http://ruby-doc.org/core/Thread.html#method-i-wakeup)
|
||||||
# and [`Thread#raise`](http://ruby-doc.org/core-2.2.0/Thread.html#method-i-raise).
|
# and [`Thread#raise`](http://ruby-doc.org/core/Thread.html#method-i-raise).
|
||||||
# `Thread#sleep` and `Thread#wakeup` will work as expected but mixing `Synchronization::Object#wait` and
|
# `Thread#sleep` and `Thread#wakeup` will work as expected but mixing `Synchronization::Object#wait` and
|
||||||
# `Thread#wakeup` will not work on all platforms.
|
# `Thread#wakeup` will not work on all platforms.
|
||||||
#
|
#
|
||||||
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