concurrent-ruby 1.1.5 → 1.1.6.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -1
- data/Gemfile +2 -2
- data/README.md +3 -0
- data/Rakefile +13 -10
- data/lib/{concurrent-ruby.rb → concurrent-ruby/concurrent-ruby.rb} +0 -0
- data/lib/{concurrent.rb → concurrent-ruby/concurrent.rb} +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/agent.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/array.rb +5 -5
- data/lib/{concurrent → concurrent-ruby/concurrent}/async.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atom.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/abstract_thread_local_var.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_boolean.rb +2 -2
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_fixnum.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_markable_reference.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_reference.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/count_down_latch.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/cyclic_barrier.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/event.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/java_count_down_latch.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/java_thread_local_var.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_atomic_boolean.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_atomic_fixnum.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_count_down_latch.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_semaphore.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/read_write_lock.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/reentrant_read_write_lock.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/ruby_thread_local_var.rb +43 -33
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/semaphore.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/thread_local_var.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic_reference/mutex_atomic.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic_reference/numeric_cas_wrapper.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomics.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/copy_on_notify_observer_set.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/copy_on_write_observer_set.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/java_non_concurrent_priority_queue.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/lock_free_stack.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/atomic_reference_map_backend.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/mri_map_backend.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/non_concurrent_map_backend.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/synchronized_map_backend.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/non_concurrent_priority_queue.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/ruby_non_concurrent_priority_queue.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/concern/deprecation.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/concern/dereferenceable.rb +2 -2
- data/lib/{concurrent → concurrent-ruby/concurrent}/concern/logging.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/concern/obligation.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/concern/observable.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/concurrent_ruby.jar +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/configuration.rb +7 -5
- data/lib/{concurrent → concurrent-ruby/concurrent}/constants.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/dataflow.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/delay.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/errors.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/exchanger.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/abstract_executor_service.rb +13 -4
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/cached_thread_pool.rb +5 -4
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/executor_service.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/fixed_thread_pool.rb +3 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/immediate_executor.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/indirect_immediate_executor.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_executor_service.rb +0 -4
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_single_thread_executor.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_thread_pool_executor.rb +20 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_executor_service.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_single_thread_executor.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_thread_pool_executor.rb +9 -2
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/safe_task_executor.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/serial_executor_service.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/serialized_execution.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/serialized_execution_delegator.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/simple_executor_service.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/single_thread_executor.rb +1 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/thread_pool_executor.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/timer_set.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/executors.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/future.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/hash.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/immutable_struct.rb +8 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/ivar.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/map.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/maybe.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/mutable_struct.rb +10 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/mvar.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/options.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/promise.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/promises.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/re_include.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/scheduled_task.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/set.rb +5 -5
- data/lib/{concurrent → concurrent-ruby/concurrent}/settable_struct.rb +10 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_lockable_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_struct.rb +11 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/condition.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/jruby_lockable_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/jruby_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/lock.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/lockable_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/mri_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/mutex_lockable_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/rbx_lockable_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/rbx_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/truffleruby_object.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/volatile.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/synchronized_delegator.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/adder.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/cheap_lockable.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/data_structures.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/power_of_two_tuple.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/striped64.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/volatile.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/xor_shift_random.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/timer_task.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/tuple.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/tvar.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/utility/at_exit.rb +1 -2
- data/lib/{concurrent → concurrent-ruby/concurrent}/utility/engine.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/utility/monotonic_time.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/utility/native_extension_loader.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/utility/native_integer.rb +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/utility/processor_counter.rb +5 -0
- data/lib/concurrent-ruby/concurrent/version.rb +3 -0
- metadata +128 -127
- data/lib/concurrent/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d40d15d364388e5637d46880c5a84600b0fd857e9e96ad749bdc1e25615d12b8
|
4
|
+
data.tar.gz: e236bbfb9bf74c815708d3fac9c0619e4d4eb791f8d6d018291724166ce54562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92bbcb46fb841cda08f0caffc07c9b163bdfde9cfdc47c1bb7103ceba5ca33315c49f7a91158336a4a4b55bb790b96978601af8efbeb9b7cd44fdc5e0a037244
|
7
|
+
data.tar.gz: c3e6b51d73d05289826844ef88bf5b1197cc06c255d93ec1ee8260411e6f7228e938f230a97943ff4a83fb5b49e4374a70531bccbbc230d4438b8bc3d6f8ba85
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
## Current
|
2
2
|
|
3
|
-
## Release v1.1.
|
3
|
+
## Release v1.1.6.pre1, edge v0.6.0.pre1 (26 Jan 2020)
|
4
|
+
|
5
|
+
concurrent-ruby:
|
6
|
+
|
7
|
+
* Allow to name executors, the name is also used to name their threads (#828)
|
8
|
+
* Implement #dup and #clone for structs (#838)
|
9
|
+
* Safer finalizers for thread local variables (#821)
|
10
|
+
* Documentation fixes
|
11
|
+
* Use Ruby's Etc.nprocessors if available (#814)
|
12
|
+
* Fix directory structure not to mess with packaging tools (#812)
|
13
|
+
* Fix termination of pools on JRuby (#840)
|
14
|
+
|
15
|
+
concurrent-ruby-edge:
|
16
|
+
|
17
|
+
* Add WrappingExecutor (#830)
|
18
|
+
|
19
|
+
## Release v1.1.5, edge v0.5.0 (10 Mar 2019)
|
4
20
|
|
5
21
|
concurrent-ruby:
|
6
22
|
|
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__), 'lib/concurrent/version')
|
4
|
-
require File.join(File.dirname(__FILE__ ), 'lib-edge/concurrent/edge/version')
|
3
|
+
require File.join(File.dirname(__FILE__), 'lib/concurrent-ruby/concurrent/version')
|
4
|
+
require File.join(File.dirname(__FILE__ ), 'lib/concurrent-ruby-edge/concurrent/edge/version')
|
5
5
|
|
6
6
|
no_path = ENV['NO_PATH']
|
7
7
|
options = no_path ? {} : { path: '.' }
|
data/README.md
CHANGED
@@ -253,6 +253,9 @@ be obeyed though. Features developed in `concurrent-ruby-edge` are expected to m
|
|
253
253
|
* [ErlangActor](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ErlangActor.html)
|
254
254
|
Actor implementation which precisely matches Erlang actor behaviour.
|
255
255
|
Requires at least Ruby 2.1 otherwise it's not loaded.
|
256
|
+
* [WrappingExecutor](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/WrappingExecutor.html)
|
257
|
+
A delegating executor which modifies each task before the task is given to
|
258
|
+
the target executor it delegates to.
|
256
259
|
|
257
260
|
## Supported Ruby versions
|
258
261
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require_relative 'lib/concurrent/version'
|
2
|
-
require_relative 'lib/concurrent/
|
1
|
+
require_relative 'lib/concurrent-ruby/concurrent/version'
|
2
|
+
require_relative 'lib/concurrent-ruby-edge/concurrent/edge/version'
|
3
|
+
require_relative 'lib/concurrent-ruby/concurrent/utility/engine'
|
3
4
|
|
4
5
|
if Concurrent.ruby_version :<, 2, 0, 0
|
5
6
|
# @!visibility private
|
@@ -16,9 +17,11 @@ edge_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby-edge.
|
|
16
17
|
|
17
18
|
require 'rake/javaextensiontask'
|
18
19
|
|
20
|
+
ENV['JRUBY_HOME'] = ENV['CONCURRENT_JRUBY_HOME'] if ENV['CONCURRENT_JRUBY_HOME'] && !Concurrent.on_jruby?
|
21
|
+
|
19
22
|
Rake::JavaExtensionTask.new('concurrent_ruby', core_gemspec) do |ext|
|
20
23
|
ext.ext_dir = 'ext/concurrent-ruby'
|
21
|
-
ext.lib_dir = 'lib/concurrent'
|
24
|
+
ext.lib_dir = 'lib/concurrent-ruby/concurrent'
|
22
25
|
end
|
23
26
|
|
24
27
|
unless Concurrent.on_jruby?
|
@@ -26,7 +29,7 @@ unless Concurrent.on_jruby?
|
|
26
29
|
|
27
30
|
Rake::ExtensionTask.new('concurrent_ruby_ext', ext_gemspec) do |ext|
|
28
31
|
ext.ext_dir = 'ext/concurrent-ruby-ext'
|
29
|
-
ext.lib_dir = 'lib/concurrent'
|
32
|
+
ext.lib_dir = 'lib/concurrent-ruby/concurrent'
|
30
33
|
ext.source_pattern = '*.{c,h}'
|
31
34
|
|
32
35
|
ext.cross_compile = true
|
@@ -43,7 +46,7 @@ namespace :repackage do
|
|
43
46
|
sh 'bundle package'
|
44
47
|
|
45
48
|
# build only the jar file not the whole gem for java platform, the jar is part the concurrent-ruby-x.y.z.gem
|
46
|
-
Rake::Task['lib/concurrent/concurrent_ruby.jar'].invoke
|
49
|
+
Rake::Task['lib/concurrent-ruby/concurrent/concurrent_ruby.jar'].invoke
|
47
50
|
|
48
51
|
# build all gem files
|
49
52
|
RakeCompilerDock.sh 'bundle install --local && bundle exec rake cross native package --trace'
|
@@ -58,7 +61,7 @@ Gem::PackageTask.new(core_gemspec) {} if core_gemspec
|
|
58
61
|
Gem::PackageTask.new(ext_gemspec) {} if ext_gemspec && !Concurrent.on_jruby?
|
59
62
|
Gem::PackageTask.new(edge_gemspec) {} if edge_gemspec
|
60
63
|
|
61
|
-
CLEAN.include('lib/concurrent/2.*', 'lib/concurrent/*.jar')
|
64
|
+
CLEAN.include('lib/concurrent-ruby/concurrent/2.*', 'lib/concurrent-ruby/concurrent/*.jar')
|
62
65
|
|
63
66
|
begin
|
64
67
|
require 'rspec'
|
@@ -163,8 +166,8 @@ begin
|
|
163
166
|
'--output-dir', output_dir,
|
164
167
|
'--main', 'tmp/README.md',
|
165
168
|
*common_yard_options)
|
166
|
-
yard.files = ['./lib/**/*.rb',
|
167
|
-
'./lib-edge/**/*.rb',
|
169
|
+
yard.files = ['./lib/concurrent-ruby/**/*.rb',
|
170
|
+
'./lib/concurrent-ruby-edge/**/*.rb',
|
168
171
|
'./ext/concurrent_ruby_ext/**/*.c',
|
169
172
|
'-',
|
170
173
|
'docs-source/thread_pools.md',
|
@@ -227,8 +230,8 @@ task :release => ['release:checks', 'release:build', 'release:test', 'release:pu
|
|
227
230
|
namespace :release do
|
228
231
|
# Depends on environment of @pitr-ch
|
229
232
|
|
230
|
-
mri_version = '2.5
|
231
|
-
jruby_version = 'jruby-9.
|
233
|
+
mri_version = '2.6.5'
|
234
|
+
jruby_version = 'jruby-9.2.9.0'
|
232
235
|
|
233
236
|
task :checks => "yard:#{current_yard_version_name}:uptodate" do
|
234
237
|
Dir.chdir(__dir__) do
|
File without changes
|
File without changes
|
File without changes
|
@@ -10,11 +10,11 @@ module Concurrent
|
|
10
10
|
# or writing at a time. This includes iteration methods like `#each`.
|
11
11
|
#
|
12
12
|
# @note `a += b` is **not** a **thread-safe** operation on
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
13
|
+
# `Concurrent::Array`. It reads array `a`, then it creates new `Concurrent::Array`
|
14
|
+
# which is concatenation of `a` and `b`, then it writes the concatenation to `a`.
|
15
|
+
# The read and write are independent operations they do not form a single atomic
|
16
|
+
# operation therefore when two `+=` operations are executed concurrently updates
|
17
|
+
# may be lost. Use `#concat` instead.
|
18
18
|
#
|
19
19
|
# @see http://ruby-doc.org/core-2.2.0/Array.html Ruby standard library `Array`
|
20
20
|
|
File without changes
|
@@ -18,7 +18,7 @@ require 'concurrent/synchronization'
|
|
18
18
|
# uncoordinated, *synchronous* change of individual values. Best used when
|
19
19
|
# the value will undergo frequent reads but only occasional, though complex,
|
20
20
|
# updates. Suitable when the result of an update must be known immediately.
|
21
|
-
# * *{Concurrent::AtomicReference}:* A simple object reference that can be
|
21
|
+
# * *{Concurrent::AtomicReference}:* A simple object reference that can be updated
|
22
22
|
# atomically. Updates are synchronous but fast. Best used when updates a
|
23
23
|
# simple set operations. Not suitable when updates are complex.
|
24
24
|
# {Concurrent::AtomicBoolean} and {Concurrent::AtomicFixnum} are similar
|
File without changes
|
@@ -41,13 +41,13 @@ module Concurrent
|
|
41
41
|
#
|
42
42
|
# Explicitly sets the value to true.
|
43
43
|
#
|
44
|
-
# @return [Boolean] true
|
44
|
+
# @return [Boolean] true if value has changed, otherwise false
|
45
45
|
|
46
46
|
# @!macro atomic_boolean_method_make_false
|
47
47
|
#
|
48
48
|
# Explicitly sets the value to false.
|
49
49
|
#
|
50
|
-
# @return [Boolean] true
|
50
|
+
# @return [Boolean] true if value has changed, otherwise false
|
51
51
|
|
52
52
|
###################################################################
|
53
53
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -32,12 +32,38 @@ module Concurrent
|
|
32
32
|
FREE = []
|
33
33
|
LOCK = Mutex.new
|
34
34
|
ARRAYS = {} # used as a hash set
|
35
|
+
# noinspection RubyClassVariableUsageInspection
|
35
36
|
@@next = 0
|
36
|
-
|
37
|
+
QUEUE = Queue.new
|
38
|
+
THREAD = Thread.new do
|
39
|
+
while true
|
40
|
+
method, i = QUEUE.pop
|
41
|
+
case method
|
42
|
+
when :thread_local_finalizer
|
43
|
+
LOCK.synchronize do
|
44
|
+
FREE.push(i)
|
45
|
+
# The cost of GC'ing a TLV is linear in the number of threads using TLVs
|
46
|
+
# But that is natural! More threads means more storage is used per TLV
|
47
|
+
# So naturally more CPU time is required to free more storage
|
48
|
+
ARRAYS.each_value do |array|
|
49
|
+
array[i] = nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
when :thread_finalizer
|
53
|
+
LOCK.synchronize do
|
54
|
+
# The thread which used this thread-local array is now gone
|
55
|
+
# So don't hold onto a reference to the array (thus blocking GC)
|
56
|
+
ARRAYS.delete(i)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private_constant :FREE, :LOCK, :ARRAYS, :QUEUE, :THREAD
|
37
63
|
|
38
64
|
# @!macro thread_local_var_method_get
|
39
65
|
def value
|
40
|
-
if array = get_threadlocal_array
|
66
|
+
if (array = get_threadlocal_array)
|
41
67
|
value = array[@index]
|
42
68
|
if value.nil?
|
43
69
|
default
|
@@ -57,10 +83,10 @@ module Concurrent
|
|
57
83
|
# We could keep the thread-local arrays in a hash, keyed by Thread
|
58
84
|
# But why? That would require locking
|
59
85
|
# Using Ruby's built-in thread-local storage is faster
|
60
|
-
unless array = get_threadlocal_array(me)
|
86
|
+
unless (array = get_threadlocal_array(me))
|
61
87
|
array = set_threadlocal_array([], me)
|
62
88
|
LOCK.synchronize { ARRAYS[array.object_id] = array }
|
63
|
-
ObjectSpace.define_finalizer(me, self.class.thread_finalizer(array))
|
89
|
+
ObjectSpace.define_finalizer(me, self.class.thread_finalizer(array.object_id))
|
64
90
|
end
|
65
91
|
array[@index] = (value.nil? ? NULL : value)
|
66
92
|
value
|
@@ -69,6 +95,7 @@ module Concurrent
|
|
69
95
|
protected
|
70
96
|
|
71
97
|
# @!visibility private
|
98
|
+
# noinspection RubyClassVariableUsageInspection
|
72
99
|
def allocate_storage
|
73
100
|
@index = LOCK.synchronize do
|
74
101
|
FREE.pop || begin
|
@@ -77,37 +104,19 @@ module Concurrent
|
|
77
104
|
result
|
78
105
|
end
|
79
106
|
end
|
80
|
-
ObjectSpace.define_finalizer(self, self.class.
|
107
|
+
ObjectSpace.define_finalizer(self, self.class.thread_local_finalizer(@index))
|
81
108
|
end
|
82
109
|
|
83
110
|
# @!visibility private
|
84
|
-
def self.
|
85
|
-
|
86
|
-
|
87
|
-
LOCK.synchronize do
|
88
|
-
FREE.push(index)
|
89
|
-
# The cost of GC'ing a TLV is linear in the number of threads using TLVs
|
90
|
-
# But that is natural! More threads means more storage is used per TLV
|
91
|
-
# So naturally more CPU time is required to free more storage
|
92
|
-
ARRAYS.each_value do |array|
|
93
|
-
array[index] = nil
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
111
|
+
def self.thread_local_finalizer(index)
|
112
|
+
# avoid error: can't be called from trap context
|
113
|
+
proc { QUEUE.push [:thread_local_finalizer, index] }
|
98
114
|
end
|
99
115
|
|
100
116
|
# @!visibility private
|
101
|
-
def self.thread_finalizer(
|
102
|
-
|
103
|
-
|
104
|
-
LOCK.synchronize do
|
105
|
-
# The thread which used this thread-local array is now gone
|
106
|
-
# So don't hold onto a reference to the array (thus blocking GC)
|
107
|
-
ARRAYS.delete(array.object_id)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
117
|
+
def self.thread_finalizer(id)
|
118
|
+
# avoid error: can't be called from trap context
|
119
|
+
proc { QUEUE.push [:thread_finalizer, id] }
|
111
120
|
end
|
112
121
|
|
113
122
|
private
|
@@ -136,21 +145,22 @@ module Concurrent
|
|
136
145
|
# This exists only for use in testing
|
137
146
|
# @!visibility private
|
138
147
|
def value_for(thread)
|
139
|
-
if array = get_threadlocal_array(thread)
|
148
|
+
if (array = get_threadlocal_array(thread))
|
140
149
|
value = array[@index]
|
141
150
|
if value.nil?
|
142
|
-
|
151
|
+
get_default
|
143
152
|
elsif value.equal?(NULL)
|
144
153
|
nil
|
145
154
|
else
|
146
155
|
value
|
147
156
|
end
|
148
157
|
else
|
149
|
-
|
158
|
+
get_default
|
150
159
|
end
|
151
160
|
end
|
152
161
|
|
153
|
-
|
162
|
+
# @!visibility private
|
163
|
+
def get_default
|
154
164
|
if @default_block
|
155
165
|
raise "Cannot use default_for with default block"
|
156
166
|
else
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/{concurrent → concurrent-ruby/concurrent}/collection/copy_on_notify_observer_set.rb
RENAMED
File without changes
|
File without changes
|
data/lib/{concurrent → concurrent-ruby/concurrent}/collection/java_non_concurrent_priority_queue.rb
RENAMED
File without changes
|
File without changes
|
data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/atomic_reference_map_backend.rb
RENAMED
File without changes
|
File without changes
|
data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/non_concurrent_map_backend.rb
RENAMED
File without changes
|
data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/synchronized_map_backend.rb
RENAMED
File without changes
|
data/lib/{concurrent → concurrent-ruby/concurrent}/collection/ruby_non_concurrent_priority_queue.rb
RENAMED
File without changes
|
File without changes
|
@@ -37,8 +37,8 @@ module Concurrent
|
|
37
37
|
# returning data to the caller (dereferencing).
|
38
38
|
#
|
39
39
|
# @note Most classes that include this module will call `#set_deref_options`
|
40
|
-
#
|
41
|
-
#
|
40
|
+
# from within the constructor, thus allowing these options to be set at
|
41
|
+
# object creation.
|
42
42
|
#
|
43
43
|
# @param [Hash] opts the options defining dereference behavior.
|
44
44
|
# @option opts [String] :dup_on_deref (false) call `#dup` before returning the data
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
@@ -115,7 +115,7 @@ module Concurrent
|
|
115
115
|
# Disables AtExit handlers including pool auto-termination handlers.
|
116
116
|
# When disabled it will be the application programmer's responsibility
|
117
117
|
# to ensure that the handlers are shutdown properly prior to application
|
118
|
-
# exit by calling
|
118
|
+
# exit by calling `AtExit.run` method.
|
119
119
|
#
|
120
120
|
# @note this option should be needed only because of `at_exit` ordering
|
121
121
|
# issues which may arise when running some of the testing frameworks.
|
@@ -125,9 +125,9 @@ module Concurrent
|
|
125
125
|
# @note This method should *never* be called
|
126
126
|
# from within a gem. It should *only* be used from within the main
|
127
127
|
# application and even then it should be used only when necessary.
|
128
|
-
#
|
128
|
+
#
|
129
129
|
def self.disable_at_exit_handlers!
|
130
|
-
|
130
|
+
AT_EXIT.enabled = false
|
131
131
|
end
|
132
132
|
|
133
133
|
# Global thread pool optimized for short, fast *operations*.
|
@@ -171,14 +171,16 @@ module Concurrent
|
|
171
171
|
auto_terminate: opts.fetch(:auto_terminate, true),
|
172
172
|
idletime: 60, # 1 minute
|
173
173
|
max_queue: 0, # unlimited
|
174
|
-
fallback_policy: :abort # shouldn't matter -- 0 max queue
|
174
|
+
fallback_policy: :abort, # shouldn't matter -- 0 max queue
|
175
|
+
name: "fast"
|
175
176
|
)
|
176
177
|
end
|
177
178
|
|
178
179
|
def self.new_io_executor(opts = {})
|
179
180
|
CachedThreadPool.new(
|
180
181
|
auto_terminate: opts.fetch(:auto_terminate, true),
|
181
|
-
fallback_policy: :abort # shouldn't matter -- 0 max queue
|
182
|
+
fallback_policy: :abort, # shouldn't matter -- 0 max queue
|
183
|
+
name: "io"
|
182
184
|
)
|
183
185
|
end
|
184
186
|
end
|