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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -1
  3. data/Gemfile +2 -2
  4. data/README.md +3 -0
  5. data/Rakefile +13 -10
  6. data/lib/{concurrent-ruby.rb → concurrent-ruby/concurrent-ruby.rb} +0 -0
  7. data/lib/{concurrent.rb → concurrent-ruby/concurrent.rb} +0 -0
  8. data/lib/{concurrent → concurrent-ruby/concurrent}/agent.rb +0 -0
  9. data/lib/{concurrent → concurrent-ruby/concurrent}/array.rb +5 -5
  10. data/lib/{concurrent → concurrent-ruby/concurrent}/async.rb +0 -0
  11. data/lib/{concurrent → concurrent-ruby/concurrent}/atom.rb +1 -1
  12. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/abstract_thread_local_var.rb +0 -0
  13. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_boolean.rb +2 -2
  14. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_fixnum.rb +0 -0
  15. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_markable_reference.rb +0 -0
  16. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_reference.rb +0 -0
  17. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/count_down_latch.rb +1 -1
  18. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/cyclic_barrier.rb +0 -0
  19. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/event.rb +0 -0
  20. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/java_count_down_latch.rb +0 -0
  21. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/java_thread_local_var.rb +0 -0
  22. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_atomic_boolean.rb +0 -0
  23. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_atomic_fixnum.rb +0 -0
  24. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_count_down_latch.rb +0 -0
  25. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_semaphore.rb +0 -0
  26. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/read_write_lock.rb +0 -0
  27. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/reentrant_read_write_lock.rb +0 -0
  28. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/ruby_thread_local_var.rb +43 -33
  29. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/semaphore.rb +0 -0
  30. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/thread_local_var.rb +1 -1
  31. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic_reference/mutex_atomic.rb +0 -0
  32. data/lib/{concurrent → concurrent-ruby/concurrent}/atomic_reference/numeric_cas_wrapper.rb +0 -0
  33. data/lib/{concurrent → concurrent-ruby/concurrent}/atomics.rb +0 -0
  34. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/copy_on_notify_observer_set.rb +0 -0
  35. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/copy_on_write_observer_set.rb +0 -0
  36. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/java_non_concurrent_priority_queue.rb +0 -0
  37. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/lock_free_stack.rb +0 -0
  38. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/atomic_reference_map_backend.rb +0 -0
  39. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/mri_map_backend.rb +0 -0
  40. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/non_concurrent_map_backend.rb +0 -0
  41. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/synchronized_map_backend.rb +0 -0
  42. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/non_concurrent_priority_queue.rb +1 -1
  43. data/lib/{concurrent → concurrent-ruby/concurrent}/collection/ruby_non_concurrent_priority_queue.rb +0 -0
  44. data/lib/{concurrent → concurrent-ruby/concurrent}/concern/deprecation.rb +0 -0
  45. data/lib/{concurrent → concurrent-ruby/concurrent}/concern/dereferenceable.rb +2 -2
  46. data/lib/{concurrent → concurrent-ruby/concurrent}/concern/logging.rb +0 -0
  47. data/lib/{concurrent → concurrent-ruby/concurrent}/concern/obligation.rb +0 -0
  48. data/lib/{concurrent → concurrent-ruby/concurrent}/concern/observable.rb +0 -0
  49. data/lib/{concurrent → concurrent-ruby/concurrent}/concurrent_ruby.jar +0 -0
  50. data/lib/{concurrent → concurrent-ruby/concurrent}/configuration.rb +7 -5
  51. data/lib/{concurrent → concurrent-ruby/concurrent}/constants.rb +0 -0
  52. data/lib/{concurrent → concurrent-ruby/concurrent}/dataflow.rb +0 -0
  53. data/lib/{concurrent → concurrent-ruby/concurrent}/delay.rb +0 -0
  54. data/lib/{concurrent → concurrent-ruby/concurrent}/errors.rb +0 -0
  55. data/lib/{concurrent → concurrent-ruby/concurrent}/exchanger.rb +0 -0
  56. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/abstract_executor_service.rb +13 -4
  57. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/cached_thread_pool.rb +5 -4
  58. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/executor_service.rb +0 -0
  59. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/fixed_thread_pool.rb +3 -0
  60. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/immediate_executor.rb +0 -0
  61. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/indirect_immediate_executor.rb +0 -0
  62. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_executor_service.rb +0 -4
  63. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_single_thread_executor.rb +0 -0
  64. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_thread_pool_executor.rb +20 -1
  65. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_executor_service.rb +0 -0
  66. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_single_thread_executor.rb +0 -0
  67. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_thread_pool_executor.rb +9 -2
  68. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/safe_task_executor.rb +0 -0
  69. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/serial_executor_service.rb +0 -0
  70. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/serialized_execution.rb +0 -0
  71. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/serialized_execution_delegator.rb +0 -0
  72. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/simple_executor_service.rb +1 -1
  73. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/single_thread_executor.rb +1 -0
  74. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/thread_pool_executor.rb +0 -0
  75. data/lib/{concurrent → concurrent-ruby/concurrent}/executor/timer_set.rb +0 -0
  76. data/lib/{concurrent → concurrent-ruby/concurrent}/executors.rb +0 -0
  77. data/lib/{concurrent → concurrent-ruby/concurrent}/future.rb +0 -0
  78. data/lib/{concurrent → concurrent-ruby/concurrent}/hash.rb +0 -0
  79. data/lib/{concurrent → concurrent-ruby/concurrent}/immutable_struct.rb +8 -0
  80. data/lib/{concurrent → concurrent-ruby/concurrent}/ivar.rb +0 -0
  81. data/lib/{concurrent → concurrent-ruby/concurrent}/map.rb +1 -1
  82. data/lib/{concurrent → concurrent-ruby/concurrent}/maybe.rb +0 -0
  83. data/lib/{concurrent → concurrent-ruby/concurrent}/mutable_struct.rb +10 -0
  84. data/lib/{concurrent → concurrent-ruby/concurrent}/mvar.rb +0 -0
  85. data/lib/{concurrent → concurrent-ruby/concurrent}/options.rb +0 -0
  86. data/lib/{concurrent → concurrent-ruby/concurrent}/promise.rb +0 -0
  87. data/lib/{concurrent → concurrent-ruby/concurrent}/promises.rb +0 -0
  88. data/lib/{concurrent → concurrent-ruby/concurrent}/re_include.rb +0 -0
  89. data/lib/{concurrent → concurrent-ruby/concurrent}/scheduled_task.rb +0 -0
  90. data/lib/{concurrent → concurrent-ruby/concurrent}/set.rb +5 -5
  91. data/lib/{concurrent → concurrent-ruby/concurrent}/settable_struct.rb +10 -0
  92. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization.rb +0 -0
  93. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_lockable_object.rb +0 -0
  94. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_object.rb +0 -0
  95. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_struct.rb +11 -0
  96. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/condition.rb +0 -0
  97. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/jruby_lockable_object.rb +0 -0
  98. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/jruby_object.rb +0 -0
  99. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/lock.rb +0 -0
  100. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/lockable_object.rb +0 -0
  101. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/mri_object.rb +0 -0
  102. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/mutex_lockable_object.rb +0 -0
  103. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/object.rb +0 -0
  104. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/rbx_lockable_object.rb +0 -0
  105. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/rbx_object.rb +0 -0
  106. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/truffleruby_object.rb +0 -0
  107. data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/volatile.rb +0 -0
  108. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/synchronized_delegator.rb +0 -0
  109. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util.rb +0 -0
  110. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/adder.rb +0 -0
  111. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/cheap_lockable.rb +0 -0
  112. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/data_structures.rb +0 -0
  113. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/power_of_two_tuple.rb +0 -0
  114. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/striped64.rb +0 -0
  115. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/volatile.rb +0 -0
  116. data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/xor_shift_random.rb +0 -0
  117. data/lib/{concurrent → concurrent-ruby/concurrent}/timer_task.rb +0 -0
  118. data/lib/{concurrent → concurrent-ruby/concurrent}/tuple.rb +0 -0
  119. data/lib/{concurrent → concurrent-ruby/concurrent}/tvar.rb +0 -0
  120. data/lib/{concurrent → concurrent-ruby/concurrent}/utility/at_exit.rb +1 -2
  121. data/lib/{concurrent → concurrent-ruby/concurrent}/utility/engine.rb +0 -0
  122. data/lib/{concurrent → concurrent-ruby/concurrent}/utility/monotonic_time.rb +0 -0
  123. data/lib/{concurrent → concurrent-ruby/concurrent}/utility/native_extension_loader.rb +0 -0
  124. data/lib/{concurrent → concurrent-ruby/concurrent}/utility/native_integer.rb +0 -0
  125. data/lib/{concurrent → concurrent-ruby/concurrent}/utility/processor_counter.rb +5 -0
  126. data/lib/concurrent-ruby/concurrent/version.rb +3 -0
  127. metadata +128 -127
  128. data/lib/concurrent/version.rb +0 -3
@@ -16,10 +16,19 @@ module Concurrent
16
16
  # @!macro executor_service_attr_reader_fallback_policy
17
17
  attr_reader :fallback_policy
18
18
 
19
+ attr_reader :name
20
+
19
21
  # Create a new thread pool.
20
- def initialize(*args, &block)
22
+ def initialize(opts = {}, &block)
21
23
  super(&nil)
22
- synchronize { ns_initialize(*args, &block) }
24
+ synchronize do
25
+ ns_initialize(opts, &block)
26
+ @name = opts.fetch(:name) if opts.key?(:name)
27
+ end
28
+ end
29
+
30
+ def to_s
31
+ name ? "#{super[0..-2]} name: #{name}>" : super
23
32
  end
24
33
 
25
34
  # @!macro executor_service_method_shutdown
@@ -116,10 +125,10 @@ module Concurrent
116
125
  def ns_auto_terminate=(value)
117
126
  case value
118
127
  when true
119
- AtExit.add(self) { terminate_at_exit }
128
+ AT_EXIT.add(self) { terminate_at_exit }
120
129
  @auto_terminate = true
121
130
  when false
122
- AtExit.delete(self)
131
+ AT_EXIT.delete(self)
123
132
  @auto_terminate = false
124
133
  else
125
134
  raise ArgumentError
@@ -37,7 +37,7 @@ module Concurrent
37
37
  #
38
38
  # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool--
39
39
  def initialize(opts = {})
40
- defaults = { idletime: DEFAULT_THREAD_IDLETIMEOUT }
40
+ defaults = { idletime: DEFAULT_THREAD_IDLETIMEOUT }
41
41
  overrides = { min_threads: 0,
42
42
  max_threads: DEFAULT_MAX_POOL_SIZE,
43
43
  max_queue: DEFAULT_MAX_QUEUE_SIZE }
@@ -51,11 +51,12 @@ module Concurrent
51
51
  def ns_initialize(opts)
52
52
  super(opts)
53
53
  if Concurrent.on_jruby?
54
- @max_queue = 0
55
- @executor = java.util.concurrent.Executors.newCachedThreadPool
54
+ self.auto_terminate = opts.fetch(:auto_terminate, true)
55
+ @max_queue = 0
56
+ @executor = java.util.concurrent.Executors.newCachedThreadPool(
57
+ DaemonThreadFactory.new(self.auto_terminate?))
56
58
  @executor.setRejectedExecutionHandler(FALLBACK_POLICY_CLASSES[@fallback_policy].new)
57
59
  @executor.setKeepAliveTime(opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT), java.util.concurrent.TimeUnit::SECONDS)
58
- self.auto_terminate = opts.fetch(:auto_terminate, true)
59
60
  end
60
61
  end
61
62
  end
@@ -115,6 +115,9 @@ module Concurrent
115
115
  # Thread pools support several configuration options:
116
116
  #
117
117
  # * `idletime`: The number of seconds that a thread may be idle before being reclaimed.
118
+ # * `name`: The name of the executor (optional). Printed in the executor's `#to_s` output and
119
+ # a `<name>-worker-<id>` name is given to its threads if supported by used Ruby
120
+ # implementation. `<id>` is uniq for each thread.
118
121
  # * `max_queue`: The maximum number of tasks that may be waiting in the work queue at
119
122
  # any one time. When the queue size reaches `max_queue` and no new threads can be created,
120
123
  # subsequent tasks will be rejected in accordance with the configured `fallback_policy`.
@@ -18,10 +18,6 @@ if Concurrent.on_jruby?
18
18
  }.freeze
19
19
  private_constant :FALLBACK_POLICY_CLASSES
20
20
 
21
- def initialize(*args, &block)
22
- super
23
- end
24
-
25
21
  def post(*args, &task)
26
22
  raise ArgumentError.new('no block given') unless block_given?
27
23
  return handle_fallback(*args, &task) unless running?
@@ -108,16 +108,35 @@ if Concurrent.on_jruby?
108
108
  queue = java.util.concurrent.LinkedBlockingQueue.new(@max_queue)
109
109
  end
110
110
 
111
+ self.auto_terminate = opts.fetch(:auto_terminate, true)
112
+
111
113
  @executor = java.util.concurrent.ThreadPoolExecutor.new(
112
114
  min_length,
113
115
  max_length,
114
116
  idletime,
115
117
  java.util.concurrent.TimeUnit::SECONDS,
116
118
  queue,
119
+ DaemonThreadFactory.new(self.auto_terminate?),
117
120
  FALLBACK_POLICY_CLASSES[@fallback_policy].new)
118
121
 
119
- self.auto_terminate = opts.fetch(:auto_terminate, true)
120
122
  end
121
123
  end
124
+
125
+ class DaemonThreadFactory
126
+ # hide include from YARD
127
+ send :include, java.util.concurrent.ThreadFactory
128
+
129
+ def initialize(daemonize = true)
130
+ @daemonize = daemonize
131
+ end
132
+
133
+ def newThread(runnable)
134
+ thread = java.util.concurrent.Executors.defaultThreadFactory().newThread(runnable)
135
+ thread.setDaemon(@daemonize)
136
+ return thread
137
+ end
138
+ end
139
+
140
+ private_constant :DaemonThreadFactory
122
141
  end
123
142
  end
@@ -131,6 +131,7 @@ module Concurrent
131
131
  @scheduled_task_count = 0
132
132
  @completed_task_count = 0
133
133
  @largest_length = 0
134
+ @workers_counter = 0
134
135
  @ruby_pid = $$ # detects if Ruby has forked
135
136
 
136
137
  @gc_interval = opts.fetch(:gc_interval, @idletime / 2.0).to_i # undocumented
@@ -224,7 +225,8 @@ module Concurrent
224
225
  def ns_add_busy_worker
225
226
  return if @pool.size >= @max_length
226
227
 
227
- @pool << (worker = Worker.new(self))
228
+ @workers_counter += 1
229
+ @pool << (worker = Worker.new(self, @workers_counter))
228
230
  @largest_length = @pool.length if @pool.length > @largest_length
229
231
  worker
230
232
  end
@@ -284,6 +286,7 @@ module Concurrent
284
286
  @scheduled_task_count = 0
285
287
  @completed_task_count = 0
286
288
  @largest_length = 0
289
+ @workers_counter = 0
287
290
  @ruby_pid = $$
288
291
  end
289
292
  end
@@ -292,11 +295,15 @@ module Concurrent
292
295
  class Worker
293
296
  include Concern::Logging
294
297
 
295
- def initialize(pool)
298
+ def initialize(pool, id)
296
299
  # instance variables accessed only under pool's lock so no need to sync here again
297
300
  @queue = Queue.new
298
301
  @pool = pool
299
302
  @thread = create_worker @queue, pool, pool.idletime
303
+
304
+ if @thread.respond_to?(:name=)
305
+ @thread.name = [pool.name, 'worker', id].compact.join('-')
306
+ end
300
307
  end
301
308
 
302
309
  def <<(message)
@@ -91,7 +91,7 @@ module Concurrent
91
91
 
92
92
  private
93
93
 
94
- def ns_initialize
94
+ def ns_initialize(*args)
95
95
  @running = Concurrent::AtomicBoolean.new(true)
96
96
  @stopped = Concurrent::Event.new
97
97
  @count = Concurrent::AtomicFixnum.new(0)
@@ -1,3 +1,4 @@
1
+ require 'concurrent/utility/engine'
1
2
  require 'concurrent/executor/ruby_single_thread_executor'
2
3
 
3
4
  module Concurrent
@@ -70,6 +70,14 @@ module Concurrent
70
70
  ns_select(&block)
71
71
  end
72
72
 
73
+ private
74
+
75
+ # @!visibility private
76
+ def initialize_copy(original)
77
+ super(original)
78
+ ns_initialize_copy
79
+ end
80
+
73
81
  # @!macro struct_new
74
82
  def self.new(*args, &block)
75
83
  clazz_name = nil
@@ -197,7 +197,7 @@ module Concurrent
197
197
  # Insert value into map with key if key is absent in one atomic step.
198
198
  # @param [Object] key
199
199
  # @param [Object] value
200
- # @return [Object, nil] the value or nil when key was present
200
+ # @return [Object, nil] the previous value when key was present or nil when there was no key
201
201
  def put_if_absent(key, value)
202
202
  computed = false
203
203
  result = compute_if_absent(key) do
@@ -196,6 +196,16 @@ module Concurrent
196
196
  raise NameError.new("no member '#{member}' in struct")
197
197
  end
198
198
 
199
+ private
200
+
201
+ # @!visibility private
202
+ def initialize_copy(original)
203
+ synchronize do
204
+ super(original)
205
+ ns_initialize_copy
206
+ end
207
+ end
208
+
199
209
  # @!macro struct_new
200
210
  def self.new(*args, &block)
201
211
  clazz_name = nil
@@ -11,11 +11,11 @@ module Concurrent
11
11
  # or writing at a time. This includes iteration methods like `#each`.
12
12
  #
13
13
  # @note `a += b` is **not** a **thread-safe** operation on
14
- # `Concurrent::Set`. It reads Set `a`, then it creates new `Concurrent::Set`
15
- # which is union of `a` and `b`, then it writes the union to `a`.
16
- # The read and write are independent operations they do not form a single atomic
17
- # operation therefore when two `+=` operations are executed concurrently updates
18
- # may be lost. Use `#merge` instead.
14
+ # `Concurrent::Set`. It reads Set `a`, then it creates new `Concurrent::Set`
15
+ # which is union of `a` and `b`, then it writes the union to `a`.
16
+ # The read and write are independent operations they do not form a single atomic
17
+ # operation therefore when two `+=` operations are executed concurrently updates
18
+ # may be lost. Use `#merge` instead.
19
19
  #
20
20
  # @see http://ruby-doc.org/stdlib-2.4.0/libdoc/set/rdoc/Set.html Ruby standard library `Set`
21
21
 
@@ -91,6 +91,16 @@ module Concurrent
91
91
  raise NameError.new("no member '#{member}' in struct")
92
92
  end
93
93
 
94
+ private
95
+
96
+ # @!visibility private
97
+ def initialize_copy(original)
98
+ synchronize do
99
+ super(original)
100
+ ns_initialize_copy
101
+ end
102
+ end
103
+
94
104
  # @!macro struct_new
95
105
  def self.new(*args, &block)
96
106
  clazz_name = nil
@@ -115,6 +115,17 @@ module Concurrent
115
115
  self.class.new(*self.to_h.merge(other, &block).values)
116
116
  end
117
117
 
118
+ # @!visibility private
119
+ def ns_initialize_copy
120
+ @values = @values.map do |val|
121
+ begin
122
+ val.clone
123
+ rescue TypeError
124
+ val
125
+ end
126
+ end
127
+ end
128
+
118
129
  # @!visibility private
119
130
  def pr_underscore(clazz)
120
131
  word = clazz.to_s.dup # dup string to workaround JRuby 9.2.0.0 bug https://github.com/jruby/jruby/issues/5229
@@ -91,7 +91,6 @@ module Concurrent
91
91
 
92
92
  private_constant :AtExitImplementation
93
93
 
94
- # @see AtExitImplementation
95
94
  # @!visibility private
96
- AtExit = AtExitImplementation.new.install
95
+ AT_EXIT = AtExitImplementation.new.install
97
96
  end
@@ -1,3 +1,4 @@
1
+ require 'etc'
1
2
  require 'rbconfig'
2
3
  require 'concurrent/delay'
3
4
 
@@ -22,6 +23,8 @@ module Concurrent
22
23
  # occasionally poll this property." Subsequently the result will NOT be
23
24
  # memoized under JRuby.
24
25
  #
26
+ # Ruby's Etc.nprocessors will be used if available (MRI 2.2+).
27
+ #
25
28
  # On Windows the Win32 API will be queried for the
26
29
  # `NumberOfLogicalProcessors from Win32_Processor`. This will return the
27
30
  # total number "logical processors for the current instance of the
@@ -76,6 +79,8 @@ module Concurrent
76
79
  def compute_processor_count
77
80
  if Concurrent.on_jruby?
78
81
  java.lang.Runtime.getRuntime.availableProcessors
82
+ elsif Etc.respond_to?(:nprocessors) && (nprocessor = Etc.nprocessors rescue nil)
83
+ nprocessor
79
84
  else
80
85
  os_name = RbConfig::CONFIG["target_os"]
81
86
  if os_name =~ /mingw|mswin/
@@ -0,0 +1,3 @@
1
+ module Concurrent
2
+ VERSION = '1.1.6.pre1'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concurrent-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry D'Antonio
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-03-11 00:00:00.000000000 Z
13
+ date: 2020-01-26 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: |
16
16
  Modern concurrency tools including agents, futures, promises, thread pools, actors, supervisors, and more.
@@ -43,136 +43,137 @@ files:
43
43
  - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/LongAdder.java
44
44
  - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/Striped64.java
45
45
  - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166y/ThreadLocalRandom.java
46
- - lib/concurrent-ruby.rb
47
- - lib/concurrent.rb
48
- - lib/concurrent/agent.rb
49
- - lib/concurrent/array.rb
50
- - lib/concurrent/async.rb
51
- - lib/concurrent/atom.rb
52
- - lib/concurrent/atomic/abstract_thread_local_var.rb
53
- - lib/concurrent/atomic/atomic_boolean.rb
54
- - lib/concurrent/atomic/atomic_fixnum.rb
55
- - lib/concurrent/atomic/atomic_markable_reference.rb
56
- - lib/concurrent/atomic/atomic_reference.rb
57
- - lib/concurrent/atomic/count_down_latch.rb
58
- - lib/concurrent/atomic/cyclic_barrier.rb
59
- - lib/concurrent/atomic/event.rb
60
- - lib/concurrent/atomic/java_count_down_latch.rb
61
- - lib/concurrent/atomic/java_thread_local_var.rb
62
- - lib/concurrent/atomic/mutex_atomic_boolean.rb
63
- - lib/concurrent/atomic/mutex_atomic_fixnum.rb
64
- - lib/concurrent/atomic/mutex_count_down_latch.rb
65
- - lib/concurrent/atomic/mutex_semaphore.rb
66
- - lib/concurrent/atomic/read_write_lock.rb
67
- - lib/concurrent/atomic/reentrant_read_write_lock.rb
68
- - lib/concurrent/atomic/ruby_thread_local_var.rb
69
- - lib/concurrent/atomic/semaphore.rb
70
- - lib/concurrent/atomic/thread_local_var.rb
71
- - lib/concurrent/atomic_reference/mutex_atomic.rb
72
- - lib/concurrent/atomic_reference/numeric_cas_wrapper.rb
73
- - lib/concurrent/atomics.rb
74
- - lib/concurrent/collection/copy_on_notify_observer_set.rb
75
- - lib/concurrent/collection/copy_on_write_observer_set.rb
76
- - lib/concurrent/collection/java_non_concurrent_priority_queue.rb
77
- - lib/concurrent/collection/lock_free_stack.rb
78
- - lib/concurrent/collection/map/atomic_reference_map_backend.rb
79
- - lib/concurrent/collection/map/mri_map_backend.rb
80
- - lib/concurrent/collection/map/non_concurrent_map_backend.rb
81
- - lib/concurrent/collection/map/synchronized_map_backend.rb
82
- - lib/concurrent/collection/non_concurrent_priority_queue.rb
83
- - lib/concurrent/collection/ruby_non_concurrent_priority_queue.rb
84
- - lib/concurrent/concern/deprecation.rb
85
- - lib/concurrent/concern/dereferenceable.rb
86
- - lib/concurrent/concern/logging.rb
87
- - lib/concurrent/concern/obligation.rb
88
- - lib/concurrent/concern/observable.rb
89
- - lib/concurrent/concurrent_ruby.jar
90
- - lib/concurrent/configuration.rb
91
- - lib/concurrent/constants.rb
92
- - lib/concurrent/dataflow.rb
93
- - lib/concurrent/delay.rb
94
- - lib/concurrent/errors.rb
95
- - lib/concurrent/exchanger.rb
96
- - lib/concurrent/executor/abstract_executor_service.rb
97
- - lib/concurrent/executor/cached_thread_pool.rb
98
- - lib/concurrent/executor/executor_service.rb
99
- - lib/concurrent/executor/fixed_thread_pool.rb
100
- - lib/concurrent/executor/immediate_executor.rb
101
- - lib/concurrent/executor/indirect_immediate_executor.rb
102
- - lib/concurrent/executor/java_executor_service.rb
103
- - lib/concurrent/executor/java_single_thread_executor.rb
104
- - lib/concurrent/executor/java_thread_pool_executor.rb
105
- - lib/concurrent/executor/ruby_executor_service.rb
106
- - lib/concurrent/executor/ruby_single_thread_executor.rb
107
- - lib/concurrent/executor/ruby_thread_pool_executor.rb
108
- - lib/concurrent/executor/safe_task_executor.rb
109
- - lib/concurrent/executor/serial_executor_service.rb
110
- - lib/concurrent/executor/serialized_execution.rb
111
- - lib/concurrent/executor/serialized_execution_delegator.rb
112
- - lib/concurrent/executor/simple_executor_service.rb
113
- - lib/concurrent/executor/single_thread_executor.rb
114
- - lib/concurrent/executor/thread_pool_executor.rb
115
- - lib/concurrent/executor/timer_set.rb
116
- - lib/concurrent/executors.rb
117
- - lib/concurrent/future.rb
118
- - lib/concurrent/hash.rb
119
- - lib/concurrent/immutable_struct.rb
120
- - lib/concurrent/ivar.rb
121
- - lib/concurrent/map.rb
122
- - lib/concurrent/maybe.rb
123
- - lib/concurrent/mutable_struct.rb
124
- - lib/concurrent/mvar.rb
125
- - lib/concurrent/options.rb
126
- - lib/concurrent/promise.rb
127
- - lib/concurrent/promises.rb
128
- - lib/concurrent/re_include.rb
129
- - lib/concurrent/scheduled_task.rb
130
- - lib/concurrent/set.rb
131
- - lib/concurrent/settable_struct.rb
132
- - lib/concurrent/synchronization.rb
133
- - lib/concurrent/synchronization/abstract_lockable_object.rb
134
- - lib/concurrent/synchronization/abstract_object.rb
135
- - lib/concurrent/synchronization/abstract_struct.rb
136
- - lib/concurrent/synchronization/condition.rb
137
- - lib/concurrent/synchronization/jruby_lockable_object.rb
138
- - lib/concurrent/synchronization/jruby_object.rb
139
- - lib/concurrent/synchronization/lock.rb
140
- - lib/concurrent/synchronization/lockable_object.rb
141
- - lib/concurrent/synchronization/mri_object.rb
142
- - lib/concurrent/synchronization/mutex_lockable_object.rb
143
- - lib/concurrent/synchronization/object.rb
144
- - lib/concurrent/synchronization/rbx_lockable_object.rb
145
- - lib/concurrent/synchronization/rbx_object.rb
146
- - lib/concurrent/synchronization/truffleruby_object.rb
147
- - lib/concurrent/synchronization/volatile.rb
148
- - lib/concurrent/thread_safe/synchronized_delegator.rb
149
- - lib/concurrent/thread_safe/util.rb
150
- - lib/concurrent/thread_safe/util/adder.rb
151
- - lib/concurrent/thread_safe/util/cheap_lockable.rb
152
- - lib/concurrent/thread_safe/util/data_structures.rb
153
- - lib/concurrent/thread_safe/util/power_of_two_tuple.rb
154
- - lib/concurrent/thread_safe/util/striped64.rb
155
- - lib/concurrent/thread_safe/util/volatile.rb
156
- - lib/concurrent/thread_safe/util/xor_shift_random.rb
157
- - lib/concurrent/timer_task.rb
158
- - lib/concurrent/tuple.rb
159
- - lib/concurrent/tvar.rb
160
- - lib/concurrent/utility/at_exit.rb
161
- - lib/concurrent/utility/engine.rb
162
- - lib/concurrent/utility/monotonic_time.rb
163
- - lib/concurrent/utility/native_extension_loader.rb
164
- - lib/concurrent/utility/native_integer.rb
165
- - lib/concurrent/utility/processor_counter.rb
166
- - lib/concurrent/version.rb
46
+ - lib/concurrent-ruby/concurrent-ruby.rb
47
+ - lib/concurrent-ruby/concurrent.rb
48
+ - lib/concurrent-ruby/concurrent/agent.rb
49
+ - lib/concurrent-ruby/concurrent/array.rb
50
+ - lib/concurrent-ruby/concurrent/async.rb
51
+ - lib/concurrent-ruby/concurrent/atom.rb
52
+ - lib/concurrent-ruby/concurrent/atomic/abstract_thread_local_var.rb
53
+ - lib/concurrent-ruby/concurrent/atomic/atomic_boolean.rb
54
+ - lib/concurrent-ruby/concurrent/atomic/atomic_fixnum.rb
55
+ - lib/concurrent-ruby/concurrent/atomic/atomic_markable_reference.rb
56
+ - lib/concurrent-ruby/concurrent/atomic/atomic_reference.rb
57
+ - lib/concurrent-ruby/concurrent/atomic/count_down_latch.rb
58
+ - lib/concurrent-ruby/concurrent/atomic/cyclic_barrier.rb
59
+ - lib/concurrent-ruby/concurrent/atomic/event.rb
60
+ - lib/concurrent-ruby/concurrent/atomic/java_count_down_latch.rb
61
+ - lib/concurrent-ruby/concurrent/atomic/java_thread_local_var.rb
62
+ - lib/concurrent-ruby/concurrent/atomic/mutex_atomic_boolean.rb
63
+ - lib/concurrent-ruby/concurrent/atomic/mutex_atomic_fixnum.rb
64
+ - lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb
65
+ - lib/concurrent-ruby/concurrent/atomic/mutex_semaphore.rb
66
+ - lib/concurrent-ruby/concurrent/atomic/read_write_lock.rb
67
+ - lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb
68
+ - lib/concurrent-ruby/concurrent/atomic/ruby_thread_local_var.rb
69
+ - lib/concurrent-ruby/concurrent/atomic/semaphore.rb
70
+ - lib/concurrent-ruby/concurrent/atomic/thread_local_var.rb
71
+ - lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
72
+ - lib/concurrent-ruby/concurrent/atomic_reference/numeric_cas_wrapper.rb
73
+ - lib/concurrent-ruby/concurrent/atomics.rb
74
+ - lib/concurrent-ruby/concurrent/collection/copy_on_notify_observer_set.rb
75
+ - lib/concurrent-ruby/concurrent/collection/copy_on_write_observer_set.rb
76
+ - lib/concurrent-ruby/concurrent/collection/java_non_concurrent_priority_queue.rb
77
+ - lib/concurrent-ruby/concurrent/collection/lock_free_stack.rb
78
+ - lib/concurrent-ruby/concurrent/collection/map/atomic_reference_map_backend.rb
79
+ - lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
80
+ - lib/concurrent-ruby/concurrent/collection/map/non_concurrent_map_backend.rb
81
+ - lib/concurrent-ruby/concurrent/collection/map/synchronized_map_backend.rb
82
+ - lib/concurrent-ruby/concurrent/collection/non_concurrent_priority_queue.rb
83
+ - lib/concurrent-ruby/concurrent/collection/ruby_non_concurrent_priority_queue.rb
84
+ - lib/concurrent-ruby/concurrent/concern/deprecation.rb
85
+ - lib/concurrent-ruby/concurrent/concern/dereferenceable.rb
86
+ - lib/concurrent-ruby/concurrent/concern/logging.rb
87
+ - lib/concurrent-ruby/concurrent/concern/obligation.rb
88
+ - lib/concurrent-ruby/concurrent/concern/observable.rb
89
+ - lib/concurrent-ruby/concurrent/concurrent_ruby.jar
90
+ - lib/concurrent-ruby/concurrent/configuration.rb
91
+ - lib/concurrent-ruby/concurrent/constants.rb
92
+ - lib/concurrent-ruby/concurrent/dataflow.rb
93
+ - lib/concurrent-ruby/concurrent/delay.rb
94
+ - lib/concurrent-ruby/concurrent/errors.rb
95
+ - lib/concurrent-ruby/concurrent/exchanger.rb
96
+ - lib/concurrent-ruby/concurrent/executor/abstract_executor_service.rb
97
+ - lib/concurrent-ruby/concurrent/executor/cached_thread_pool.rb
98
+ - lib/concurrent-ruby/concurrent/executor/executor_service.rb
99
+ - lib/concurrent-ruby/concurrent/executor/fixed_thread_pool.rb
100
+ - lib/concurrent-ruby/concurrent/executor/immediate_executor.rb
101
+ - lib/concurrent-ruby/concurrent/executor/indirect_immediate_executor.rb
102
+ - lib/concurrent-ruby/concurrent/executor/java_executor_service.rb
103
+ - lib/concurrent-ruby/concurrent/executor/java_single_thread_executor.rb
104
+ - lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb
105
+ - lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb
106
+ - lib/concurrent-ruby/concurrent/executor/ruby_single_thread_executor.rb
107
+ - lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb
108
+ - lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb
109
+ - lib/concurrent-ruby/concurrent/executor/serial_executor_service.rb
110
+ - lib/concurrent-ruby/concurrent/executor/serialized_execution.rb
111
+ - lib/concurrent-ruby/concurrent/executor/serialized_execution_delegator.rb
112
+ - lib/concurrent-ruby/concurrent/executor/simple_executor_service.rb
113
+ - lib/concurrent-ruby/concurrent/executor/single_thread_executor.rb
114
+ - lib/concurrent-ruby/concurrent/executor/thread_pool_executor.rb
115
+ - lib/concurrent-ruby/concurrent/executor/timer_set.rb
116
+ - lib/concurrent-ruby/concurrent/executors.rb
117
+ - lib/concurrent-ruby/concurrent/future.rb
118
+ - lib/concurrent-ruby/concurrent/hash.rb
119
+ - lib/concurrent-ruby/concurrent/immutable_struct.rb
120
+ - lib/concurrent-ruby/concurrent/ivar.rb
121
+ - lib/concurrent-ruby/concurrent/map.rb
122
+ - lib/concurrent-ruby/concurrent/maybe.rb
123
+ - lib/concurrent-ruby/concurrent/mutable_struct.rb
124
+ - lib/concurrent-ruby/concurrent/mvar.rb
125
+ - lib/concurrent-ruby/concurrent/options.rb
126
+ - lib/concurrent-ruby/concurrent/promise.rb
127
+ - lib/concurrent-ruby/concurrent/promises.rb
128
+ - lib/concurrent-ruby/concurrent/re_include.rb
129
+ - lib/concurrent-ruby/concurrent/scheduled_task.rb
130
+ - lib/concurrent-ruby/concurrent/set.rb
131
+ - lib/concurrent-ruby/concurrent/settable_struct.rb
132
+ - lib/concurrent-ruby/concurrent/synchronization.rb
133
+ - lib/concurrent-ruby/concurrent/synchronization/abstract_lockable_object.rb
134
+ - lib/concurrent-ruby/concurrent/synchronization/abstract_object.rb
135
+ - lib/concurrent-ruby/concurrent/synchronization/abstract_struct.rb
136
+ - lib/concurrent-ruby/concurrent/synchronization/condition.rb
137
+ - lib/concurrent-ruby/concurrent/synchronization/jruby_lockable_object.rb
138
+ - lib/concurrent-ruby/concurrent/synchronization/jruby_object.rb
139
+ - lib/concurrent-ruby/concurrent/synchronization/lock.rb
140
+ - lib/concurrent-ruby/concurrent/synchronization/lockable_object.rb
141
+ - lib/concurrent-ruby/concurrent/synchronization/mri_object.rb
142
+ - lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
143
+ - lib/concurrent-ruby/concurrent/synchronization/object.rb
144
+ - lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
145
+ - lib/concurrent-ruby/concurrent/synchronization/rbx_object.rb
146
+ - lib/concurrent-ruby/concurrent/synchronization/truffleruby_object.rb
147
+ - lib/concurrent-ruby/concurrent/synchronization/volatile.rb
148
+ - lib/concurrent-ruby/concurrent/thread_safe/synchronized_delegator.rb
149
+ - lib/concurrent-ruby/concurrent/thread_safe/util.rb
150
+ - lib/concurrent-ruby/concurrent/thread_safe/util/adder.rb
151
+ - lib/concurrent-ruby/concurrent/thread_safe/util/cheap_lockable.rb
152
+ - lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb
153
+ - lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
154
+ - lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb
155
+ - lib/concurrent-ruby/concurrent/thread_safe/util/volatile.rb
156
+ - lib/concurrent-ruby/concurrent/thread_safe/util/xor_shift_random.rb
157
+ - lib/concurrent-ruby/concurrent/timer_task.rb
158
+ - lib/concurrent-ruby/concurrent/tuple.rb
159
+ - lib/concurrent-ruby/concurrent/tvar.rb
160
+ - lib/concurrent-ruby/concurrent/utility/at_exit.rb
161
+ - lib/concurrent-ruby/concurrent/utility/engine.rb
162
+ - lib/concurrent-ruby/concurrent/utility/monotonic_time.rb
163
+ - lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
164
+ - lib/concurrent-ruby/concurrent/utility/native_integer.rb
165
+ - lib/concurrent-ruby/concurrent/utility/processor_counter.rb
166
+ - lib/concurrent-ruby/concurrent/version.rb
167
167
  homepage: http://www.concurrent-ruby.com
168
168
  licenses:
169
169
  - MIT
170
170
  metadata:
171
171
  source_code_uri: https://github.com/ruby-concurrency/concurrent-ruby
172
+ changelog_uri: https://github.com/ruby-concurrency/concurrent-ruby/blob/master/CHANGELOG.md
172
173
  post_install_message:
173
174
  rdoc_options: []
174
175
  require_paths:
175
- - lib
176
+ - lib/concurrent-ruby
176
177
  required_ruby_version: !ruby/object:Gem::Requirement
177
178
  requirements:
178
179
  - - ">="
@@ -180,12 +181,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
181
  version: 1.9.3
181
182
  required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  requirements:
183
- - - ">="
184
+ - - ">"
184
185
  - !ruby/object:Gem::Version
185
- version: '0'
186
+ version: 1.3.1
186
187
  requirements: []
187
188
  rubyforge_project:
188
- rubygems_version: 2.7.8
189
+ rubygems_version: 2.7.9
189
190
  signing_key:
190
191
  specification_version: 4
191
192
  summary: Modern concurrency tools for Ruby. Inspired by Erlang, Clojure, Scala, Haskell,