concurrent-ruby 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +478 -0
  3. data/Gemfile +41 -0
  4. data/LICENSE.md +23 -0
  5. data/README.md +381 -0
  6. data/Rakefile +327 -0
  7. data/ext/concurrent-ruby/ConcurrentRubyService.java +17 -0
  8. data/ext/concurrent-ruby/com/concurrent_ruby/ext/AtomicReferenceLibrary.java +175 -0
  9. data/ext/concurrent-ruby/com/concurrent_ruby/ext/JRubyMapBackendLibrary.java +248 -0
  10. data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicBooleanLibrary.java +93 -0
  11. data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicFixnumLibrary.java +113 -0
  12. data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaSemaphoreLibrary.java +159 -0
  13. data/ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java +307 -0
  14. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMap.java +31 -0
  15. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java +3863 -0
  16. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/LongAdder.java +203 -0
  17. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java +342 -0
  18. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java +3800 -0
  19. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/LongAdder.java +204 -0
  20. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/Striped64.java +291 -0
  21. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166y/ThreadLocalRandom.java +199 -0
  22. data/lib/concurrent-ruby.rb +1 -0
  23. data/lib/concurrent.rb +134 -0
  24. data/lib/concurrent/agent.rb +587 -0
  25. data/lib/concurrent/array.rb +66 -0
  26. data/lib/concurrent/async.rb +459 -0
  27. data/lib/concurrent/atom.rb +222 -0
  28. data/lib/concurrent/atomic/abstract_thread_local_var.rb +66 -0
  29. data/lib/concurrent/atomic/atomic_boolean.rb +126 -0
  30. data/lib/concurrent/atomic/atomic_fixnum.rb +143 -0
  31. data/lib/concurrent/atomic/atomic_markable_reference.rb +164 -0
  32. data/lib/concurrent/atomic/atomic_reference.rb +204 -0
  33. data/lib/concurrent/atomic/count_down_latch.rb +100 -0
  34. data/lib/concurrent/atomic/cyclic_barrier.rb +128 -0
  35. data/lib/concurrent/atomic/event.rb +109 -0
  36. data/lib/concurrent/atomic/java_count_down_latch.rb +42 -0
  37. data/lib/concurrent/atomic/java_thread_local_var.rb +37 -0
  38. data/lib/concurrent/atomic/mutex_atomic_boolean.rb +62 -0
  39. data/lib/concurrent/atomic/mutex_atomic_fixnum.rb +75 -0
  40. data/lib/concurrent/atomic/mutex_count_down_latch.rb +44 -0
  41. data/lib/concurrent/atomic/mutex_semaphore.rb +115 -0
  42. data/lib/concurrent/atomic/read_write_lock.rb +254 -0
  43. data/lib/concurrent/atomic/reentrant_read_write_lock.rb +379 -0
  44. data/lib/concurrent/atomic/ruby_thread_local_var.rb +161 -0
  45. data/lib/concurrent/atomic/semaphore.rb +145 -0
  46. data/lib/concurrent/atomic/thread_local_var.rb +104 -0
  47. data/lib/concurrent/atomic_reference/mutex_atomic.rb +56 -0
  48. data/lib/concurrent/atomic_reference/numeric_cas_wrapper.rb +28 -0
  49. data/lib/concurrent/atomics.rb +10 -0
  50. data/lib/concurrent/collection/copy_on_notify_observer_set.rb +107 -0
  51. data/lib/concurrent/collection/copy_on_write_observer_set.rb +111 -0
  52. data/lib/concurrent/collection/java_non_concurrent_priority_queue.rb +84 -0
  53. data/lib/concurrent/collection/lock_free_stack.rb +158 -0
  54. data/lib/concurrent/collection/map/atomic_reference_map_backend.rb +927 -0
  55. data/lib/concurrent/collection/map/mri_map_backend.rb +66 -0
  56. data/lib/concurrent/collection/map/non_concurrent_map_backend.rb +140 -0
  57. data/lib/concurrent/collection/map/synchronized_map_backend.rb +82 -0
  58. data/lib/concurrent/collection/non_concurrent_priority_queue.rb +143 -0
  59. data/lib/concurrent/collection/ruby_non_concurrent_priority_queue.rb +150 -0
  60. data/lib/concurrent/concern/deprecation.rb +34 -0
  61. data/lib/concurrent/concern/dereferenceable.rb +73 -0
  62. data/lib/concurrent/concern/logging.rb +32 -0
  63. data/lib/concurrent/concern/obligation.rb +220 -0
  64. data/lib/concurrent/concern/observable.rb +110 -0
  65. data/lib/concurrent/concurrent_ruby.jar +0 -0
  66. data/lib/concurrent/configuration.rb +184 -0
  67. data/lib/concurrent/constants.rb +8 -0
  68. data/lib/concurrent/dataflow.rb +81 -0
  69. data/lib/concurrent/delay.rb +199 -0
  70. data/lib/concurrent/errors.rb +69 -0
  71. data/lib/concurrent/exchanger.rb +352 -0
  72. data/lib/concurrent/executor/abstract_executor_service.rb +134 -0
  73. data/lib/concurrent/executor/cached_thread_pool.rb +62 -0
  74. data/lib/concurrent/executor/executor_service.rb +185 -0
  75. data/lib/concurrent/executor/fixed_thread_pool.rb +206 -0
  76. data/lib/concurrent/executor/immediate_executor.rb +66 -0
  77. data/lib/concurrent/executor/indirect_immediate_executor.rb +44 -0
  78. data/lib/concurrent/executor/java_executor_service.rb +91 -0
  79. data/lib/concurrent/executor/java_single_thread_executor.rb +29 -0
  80. data/lib/concurrent/executor/java_thread_pool_executor.rb +123 -0
  81. data/lib/concurrent/executor/ruby_executor_service.rb +78 -0
  82. data/lib/concurrent/executor/ruby_single_thread_executor.rb +22 -0
  83. data/lib/concurrent/executor/ruby_thread_pool_executor.rb +362 -0
  84. data/lib/concurrent/executor/safe_task_executor.rb +35 -0
  85. data/lib/concurrent/executor/serial_executor_service.rb +34 -0
  86. data/lib/concurrent/executor/serialized_execution.rb +107 -0
  87. data/lib/concurrent/executor/serialized_execution_delegator.rb +28 -0
  88. data/lib/concurrent/executor/simple_executor_service.rb +100 -0
  89. data/lib/concurrent/executor/single_thread_executor.rb +56 -0
  90. data/lib/concurrent/executor/thread_pool_executor.rb +87 -0
  91. data/lib/concurrent/executor/timer_set.rb +173 -0
  92. data/lib/concurrent/executors.rb +20 -0
  93. data/lib/concurrent/future.rb +141 -0
  94. data/lib/concurrent/hash.rb +59 -0
  95. data/lib/concurrent/immutable_struct.rb +93 -0
  96. data/lib/concurrent/ivar.rb +207 -0
  97. data/lib/concurrent/map.rb +337 -0
  98. data/lib/concurrent/maybe.rb +229 -0
  99. data/lib/concurrent/mutable_struct.rb +229 -0
  100. data/lib/concurrent/mvar.rb +242 -0
  101. data/lib/concurrent/options.rb +42 -0
  102. data/lib/concurrent/promise.rb +579 -0
  103. data/lib/concurrent/promises.rb +2167 -0
  104. data/lib/concurrent/re_include.rb +58 -0
  105. data/lib/concurrent/scheduled_task.rb +318 -0
  106. data/lib/concurrent/set.rb +66 -0
  107. data/lib/concurrent/settable_struct.rb +129 -0
  108. data/lib/concurrent/synchronization.rb +30 -0
  109. data/lib/concurrent/synchronization/abstract_lockable_object.rb +98 -0
  110. data/lib/concurrent/synchronization/abstract_object.rb +24 -0
  111. data/lib/concurrent/synchronization/abstract_struct.rb +160 -0
  112. data/lib/concurrent/synchronization/condition.rb +60 -0
  113. data/lib/concurrent/synchronization/jruby_lockable_object.rb +13 -0
  114. data/lib/concurrent/synchronization/jruby_object.rb +45 -0
  115. data/lib/concurrent/synchronization/lock.rb +36 -0
  116. data/lib/concurrent/synchronization/lockable_object.rb +74 -0
  117. data/lib/concurrent/synchronization/mri_object.rb +44 -0
  118. data/lib/concurrent/synchronization/mutex_lockable_object.rb +76 -0
  119. data/lib/concurrent/synchronization/object.rb +183 -0
  120. data/lib/concurrent/synchronization/rbx_lockable_object.rb +65 -0
  121. data/lib/concurrent/synchronization/rbx_object.rb +49 -0
  122. data/lib/concurrent/synchronization/truffleruby_object.rb +47 -0
  123. data/lib/concurrent/synchronization/volatile.rb +36 -0
  124. data/lib/concurrent/thread_safe/synchronized_delegator.rb +50 -0
  125. data/lib/concurrent/thread_safe/util.rb +16 -0
  126. data/lib/concurrent/thread_safe/util/adder.rb +74 -0
  127. data/lib/concurrent/thread_safe/util/cheap_lockable.rb +118 -0
  128. data/lib/concurrent/thread_safe/util/data_structures.rb +63 -0
  129. data/lib/concurrent/thread_safe/util/power_of_two_tuple.rb +38 -0
  130. data/lib/concurrent/thread_safe/util/striped64.rb +246 -0
  131. data/lib/concurrent/thread_safe/util/volatile.rb +75 -0
  132. data/lib/concurrent/thread_safe/util/xor_shift_random.rb +50 -0
  133. data/lib/concurrent/timer_task.rb +334 -0
  134. data/lib/concurrent/tuple.rb +86 -0
  135. data/lib/concurrent/tvar.rb +258 -0
  136. data/lib/concurrent/utility/at_exit.rb +97 -0
  137. data/lib/concurrent/utility/engine.rb +56 -0
  138. data/lib/concurrent/utility/monotonic_time.rb +58 -0
  139. data/lib/concurrent/utility/native_extension_loader.rb +79 -0
  140. data/lib/concurrent/utility/native_integer.rb +53 -0
  141. data/lib/concurrent/utility/processor_counter.rb +158 -0
  142. data/lib/concurrent/version.rb +3 -0
  143. metadata +193 -0
@@ -0,0 +1,58 @@
1
+ require 'concurrent/synchronization'
2
+
3
+ module Concurrent
4
+
5
+ class_definition = Class.new(Synchronization::LockableObject) do
6
+ def initialize
7
+ @last_time = Time.now.to_f
8
+ super()
9
+ end
10
+
11
+ if defined?(Process::CLOCK_MONOTONIC)
12
+ # @!visibility private
13
+ def get_time
14
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
15
+ end
16
+ elsif Concurrent.on_jruby?
17
+ # @!visibility private
18
+ def get_time
19
+ java.lang.System.nanoTime() / 1_000_000_000.0
20
+ end
21
+ else
22
+
23
+ # @!visibility private
24
+ def get_time
25
+ synchronize do
26
+ now = Time.now.to_f
27
+ if @last_time < now
28
+ @last_time = now
29
+ else # clock has moved back in time
30
+ @last_time += 0.000_001
31
+ end
32
+ end
33
+ end
34
+
35
+ end
36
+ end
37
+
38
+ # Clock that cannot be set and represents monotonic time since
39
+ # some unspecified starting point.
40
+ #
41
+ # @!visibility private
42
+ GLOBAL_MONOTONIC_CLOCK = class_definition.new
43
+ private_constant :GLOBAL_MONOTONIC_CLOCK
44
+
45
+ # @!macro monotonic_get_time
46
+ #
47
+ # Returns the current time a tracked by the application monotonic clock.
48
+ #
49
+ # @return [Float] The current monotonic time since some unspecified
50
+ # starting point
51
+ #
52
+ # @!macro monotonic_clock_warning
53
+ def monotonic_time
54
+ GLOBAL_MONOTONIC_CLOCK.get_time
55
+ end
56
+
57
+ module_function :monotonic_time
58
+ end
@@ -0,0 +1,79 @@
1
+ require 'concurrent/utility/engine'
2
+
3
+ module Concurrent
4
+
5
+ module Utility
6
+
7
+ # @!visibility private
8
+ module NativeExtensionLoader
9
+
10
+ def allow_c_extensions?
11
+ Concurrent.on_cruby?
12
+ end
13
+
14
+ def c_extensions_loaded?
15
+ defined?(@c_extensions_loaded) && @c_extensions_loaded
16
+ end
17
+
18
+ def java_extensions_loaded?
19
+ defined?(@java_extensions_loaded) && @java_extensions_loaded
20
+ end
21
+
22
+ def load_native_extensions
23
+ unless defined? Synchronization::AbstractObject
24
+ raise 'native_extension_loader loaded before Synchronization::AbstractObject'
25
+ end
26
+
27
+ if Concurrent.on_cruby? && !c_extensions_loaded?
28
+ ['concurrent/concurrent_ruby_ext',
29
+ "concurrent/#{RUBY_VERSION[0..2]}/concurrent_ruby_ext"
30
+ ].each { |p| try_load_c_extension p }
31
+ end
32
+
33
+ if Concurrent.on_jruby? && !java_extensions_loaded?
34
+ begin
35
+ require 'concurrent/concurrent_ruby.jar'
36
+ set_java_extensions_loaded
37
+ rescue LoadError => e
38
+ raise e, "Java extensions are required for JRuby.\n" + e.message, e.backtrace
39
+ end
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def load_error_path(error)
46
+ if error.respond_to? :path
47
+ error.path
48
+ else
49
+ error.message.split(' -- ').last
50
+ end
51
+ end
52
+
53
+ def set_c_extensions_loaded
54
+ @c_extensions_loaded = true
55
+ end
56
+
57
+ def set_java_extensions_loaded
58
+ @java_extensions_loaded = true
59
+ end
60
+
61
+ def try_load_c_extension(path)
62
+ require path
63
+ set_c_extensions_loaded
64
+ rescue LoadError => e
65
+ if load_error_path(e) == path
66
+ # move on with pure-Ruby implementations
67
+ # TODO (pitr-ch 12-Jul-2018): warning on verbose?
68
+ else
69
+ raise e
70
+ end
71
+ end
72
+
73
+ end
74
+ end
75
+
76
+ # @!visibility private
77
+ extend Utility::NativeExtensionLoader
78
+ end
79
+
@@ -0,0 +1,53 @@
1
+ module Concurrent
2
+ module Utility
3
+ # @private
4
+ module NativeInteger
5
+ # http://stackoverflow.com/questions/535721/ruby-max-integer
6
+ MIN_VALUE = -(2**(0.size * 8 - 2))
7
+ MAX_VALUE = (2**(0.size * 8 - 2) - 1)
8
+
9
+ def ensure_upper_bound(value)
10
+ if value > MAX_VALUE
11
+ raise RangeError.new("#{value} is greater than the maximum value of #{MAX_VALUE}")
12
+ end
13
+ value
14
+ end
15
+
16
+ def ensure_lower_bound(value)
17
+ if value < MIN_VALUE
18
+ raise RangeError.new("#{value} is less than the maximum value of #{MIN_VALUE}")
19
+ end
20
+ value
21
+ end
22
+
23
+ def ensure_integer(value)
24
+ unless value.is_a?(Integer)
25
+ raise ArgumentError.new("#{value} is not an Integer")
26
+ end
27
+ value
28
+ end
29
+
30
+ def ensure_integer_and_bounds(value)
31
+ ensure_integer value
32
+ ensure_upper_bound value
33
+ ensure_lower_bound value
34
+ end
35
+
36
+ def ensure_positive(value)
37
+ if value < 0
38
+ raise ArgumentError.new("#{value} cannot be negative")
39
+ end
40
+ value
41
+ end
42
+
43
+ def ensure_positive_and_no_zero(value)
44
+ if value < 1
45
+ raise ArgumentError.new("#{value} cannot be negative or zero")
46
+ end
47
+ value
48
+ end
49
+
50
+ extend self
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,158 @@
1
+ require 'rbconfig'
2
+ require 'concurrent/delay'
3
+
4
+ module Concurrent
5
+ module Utility
6
+
7
+ # @!visibility private
8
+ class ProcessorCounter
9
+ def initialize
10
+ @processor_count = Delay.new { compute_processor_count }
11
+ @physical_processor_count = Delay.new { compute_physical_processor_count }
12
+ end
13
+
14
+ # Number of processors seen by the OS and used for process scheduling. For
15
+ # performance reasons the calculated value will be memoized on the first
16
+ # call.
17
+ #
18
+ # When running under JRuby the Java runtime call
19
+ # `java.lang.Runtime.getRuntime.availableProcessors` will be used. According
20
+ # to the Java documentation this "value may change during a particular
21
+ # invocation of the virtual machine... [applications] should therefore
22
+ # occasionally poll this property." Subsequently the result will NOT be
23
+ # memoized under JRuby.
24
+ #
25
+ # On Windows the Win32 API will be queried for the
26
+ # `NumberOfLogicalProcessors from Win32_Processor`. This will return the
27
+ # total number "logical processors for the current instance of the
28
+ # processor", which taked into account hyperthreading.
29
+ #
30
+ # * AIX: /usr/sbin/pmcycles (AIX 5+), /usr/sbin/lsdev
31
+ # * Alpha: /usr/bin/nproc (/proc/cpuinfo exists but cannot be used)
32
+ # * BSD: /sbin/sysctl
33
+ # * Cygwin: /proc/cpuinfo
34
+ # * Darwin: /usr/bin/hwprefs, /usr/sbin/sysctl
35
+ # * HP-UX: /usr/sbin/ioscan
36
+ # * IRIX: /usr/sbin/sysconf
37
+ # * Linux: /proc/cpuinfo
38
+ # * Minix 3+: /proc/cpuinfo
39
+ # * Solaris: /usr/sbin/psrinfo
40
+ # * Tru64 UNIX: /usr/sbin/psrinfo
41
+ # * UnixWare: /usr/sbin/psrinfo
42
+ #
43
+ # @return [Integer] number of processors seen by the OS or Java runtime
44
+ #
45
+ # @see https://github.com/grosser/parallel/blob/4fc8b89d08c7091fe0419ca8fba1ec3ce5a8d185/lib/parallel.rb
46
+ #
47
+ # @see http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html#availableProcessors()
48
+ # @see http://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx
49
+ def processor_count
50
+ @processor_count.value
51
+ end
52
+
53
+ # Number of physical processor cores on the current system. For performance
54
+ # reasons the calculated value will be memoized on the first call.
55
+ #
56
+ # On Windows the Win32 API will be queried for the `NumberOfCores from
57
+ # Win32_Processor`. This will return the total number "of cores for the
58
+ # current instance of the processor." On Unix-like operating systems either
59
+ # the `hwprefs` or `sysctl` utility will be called in a subshell and the
60
+ # returned value will be used. In the rare case where none of these methods
61
+ # work or an exception is raised the function will simply return 1.
62
+ #
63
+ # @return [Integer] number physical processor cores on the current system
64
+ #
65
+ # @see https://github.com/grosser/parallel/blob/4fc8b89d08c7091fe0419ca8fba1ec3ce5a8d185/lib/parallel.rb
66
+ #
67
+ # @see http://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx
68
+ # @see http://www.unix.com/man-page/osx/1/HWPREFS/
69
+ # @see http://linux.die.net/man/8/sysctl
70
+ def physical_processor_count
71
+ @physical_processor_count.value
72
+ end
73
+
74
+ private
75
+
76
+ def compute_processor_count
77
+ if Concurrent.on_jruby?
78
+ java.lang.Runtime.getRuntime.availableProcessors
79
+ else
80
+ os_name = RbConfig::CONFIG["target_os"]
81
+ if os_name =~ /mingw|mswin/
82
+ require 'win32ole'
83
+ result = WIN32OLE.connect("winmgmts://").ExecQuery(
84
+ "select NumberOfLogicalProcessors from Win32_Processor")
85
+ result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
86
+ elsif File.readable?("/proc/cpuinfo") && (cpuinfo_count = IO.read("/proc/cpuinfo").scan(/^processor/).size) > 0
87
+ cpuinfo_count
88
+ elsif File.executable?("/usr/bin/nproc")
89
+ IO.popen("/usr/bin/nproc --all", &:read).to_i
90
+ elsif File.executable?("/usr/bin/hwprefs")
91
+ IO.popen("/usr/bin/hwprefs thread_count", &:read).to_i
92
+ elsif File.executable?("/usr/sbin/psrinfo")
93
+ IO.popen("/usr/sbin/psrinfo", &:read).scan(/^.*on-*line/).size
94
+ elsif File.executable?("/usr/sbin/ioscan")
95
+ IO.popen("/usr/sbin/ioscan -kC processor", &:read).scan(/^.*processor/).size
96
+ elsif File.executable?("/usr/sbin/pmcycles")
97
+ IO.popen("/usr/sbin/pmcycles -m", &:read).count("\n")
98
+ elsif File.executable?("/usr/sbin/lsdev")
99
+ IO.popen("/usr/sbin/lsdev -Cc processor -S 1", &:read).count("\n")
100
+ elsif File.executable?("/usr/sbin/sysconf") and os_name =~ /irix/i
101
+ IO.popen("/usr/sbin/sysconf NPROC_ONLN", &:read).to_i
102
+ elsif File.executable?("/usr/sbin/sysctl")
103
+ IO.popen("/usr/sbin/sysctl -n hw.ncpu", &:read).to_i
104
+ elsif File.executable?("/sbin/sysctl")
105
+ IO.popen("/sbin/sysctl -n hw.ncpu", &:read).to_i
106
+ else
107
+ # TODO (pitr-ch 05-Nov-2016): warn about failures
108
+ 1
109
+ end
110
+ end
111
+ rescue
112
+ return 1
113
+ end
114
+
115
+ def compute_physical_processor_count
116
+ ppc = case RbConfig::CONFIG["target_os"]
117
+ when /darwin1/
118
+ IO.popen("/usr/sbin/sysctl -n hw.physicalcpu", &:read).to_i
119
+ when /linux/
120
+ cores = {} # unique physical ID / core ID combinations
121
+ phy = 0
122
+ IO.read("/proc/cpuinfo").scan(/^physical id.*|^core id.*/) do |ln|
123
+ if ln.start_with?("physical")
124
+ phy = ln[/\d+/]
125
+ elsif ln.start_with?("core")
126
+ cid = phy + ":" + ln[/\d+/]
127
+ cores[cid] = true if not cores[cid]
128
+ end
129
+ end
130
+ cores.count
131
+ when /mswin|mingw/
132
+ require 'win32ole'
133
+ result_set = WIN32OLE.connect("winmgmts://").ExecQuery(
134
+ "select NumberOfCores from Win32_Processor")
135
+ result_set.to_enum.collect(&:NumberOfCores).reduce(:+)
136
+ else
137
+ processor_count
138
+ end
139
+ # fall back to logical count if physical info is invalid
140
+ ppc > 0 ? ppc : processor_count
141
+ rescue
142
+ return 1
143
+ end
144
+ end
145
+ end
146
+
147
+ # create the default ProcessorCounter on load
148
+ @processor_counter = Utility::ProcessorCounter.new
149
+ singleton_class.send :attr_reader, :processor_counter
150
+
151
+ def self.processor_count
152
+ processor_counter.processor_count
153
+ end
154
+
155
+ def self.physical_processor_count
156
+ processor_counter.physical_processor_count
157
+ end
158
+ end
@@ -0,0 +1,3 @@
1
+ module Concurrent
2
+ VERSION = '1.1.5'
3
+ end
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: concurrent-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Jerry D'Antonio
8
+ - Petr Chalupa
9
+ - The Ruby Concurrency Team
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2019-03-11 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: |
16
+ Modern concurrency tools including agents, futures, promises, thread pools, actors, supervisors, and more.
17
+ Inspired by Erlang, Clojure, Go, JavaScript, actors, and classic concurrency patterns.
18
+ email: concurrent-ruby@googlegroups.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files:
22
+ - README.md
23
+ - LICENSE.md
24
+ - CHANGELOG.md
25
+ files:
26
+ - CHANGELOG.md
27
+ - Gemfile
28
+ - LICENSE.md
29
+ - README.md
30
+ - Rakefile
31
+ - ext/concurrent-ruby/ConcurrentRubyService.java
32
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/AtomicReferenceLibrary.java
33
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/JRubyMapBackendLibrary.java
34
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicBooleanLibrary.java
35
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicFixnumLibrary.java
36
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/JavaSemaphoreLibrary.java
37
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java
38
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMap.java
39
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java
40
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/LongAdder.java
41
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java
42
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java
43
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/LongAdder.java
44
+ - ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/Striped64.java
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
167
+ homepage: http://www.concurrent-ruby.com
168
+ licenses:
169
+ - MIT
170
+ metadata:
171
+ source_code_uri: https://github.com/ruby-concurrency/concurrent-ruby
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 1.9.3
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project:
188
+ rubygems_version: 2.7.8
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: Modern concurrency tools for Ruby. Inspired by Erlang, Clojure, Scala, Haskell,
192
+ F#, C#, Java, and classic concurrency patterns.
193
+ test_files: []