concurrent-ruby 1.0.5 → 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +155 -0
- data/Gemfile +37 -0
- data/LICENSE.txt +18 -18
- data/README.md +260 -103
- data/Rakefile +329 -0
- data/ext/concurrent-ruby/ConcurrentRubyService.java +17 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/AtomicReferenceLibrary.java +175 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/JRubyMapBackendLibrary.java +248 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicBooleanLibrary.java +93 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicFixnumLibrary.java +113 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaSemaphoreLibrary.java +189 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java +307 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMap.java +31 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java +3863 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/LongAdder.java +203 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java +342 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java +3800 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/LongAdder.java +204 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/Striped64.java +291 -0
- data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166y/ThreadLocalRandom.java +199 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/agent.rb +7 -7
- data/lib/concurrent-ruby/concurrent/array.rb +66 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/async.rb +28 -24
- data/lib/{concurrent → concurrent-ruby/concurrent}/atom.rb +10 -10
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_boolean.rb +26 -22
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/atomic_fixnum.rb +27 -23
- data/lib/concurrent-ruby/concurrent/atomic/atomic_markable_reference.rb +164 -0
- data/lib/concurrent-ruby/concurrent/atomic/atomic_reference.rb +205 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/count_down_latch.rb +7 -7
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/cyclic_barrier.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/event.rb +3 -3
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/java_count_down_latch.rb +9 -6
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_atomic_boolean.rb +2 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_count_down_latch.rb +1 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/mutex_semaphore.rb +18 -2
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/read_write_lock.rb +2 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/reentrant_read_write_lock.rb +7 -7
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/ruby_thread_local_var.rb +60 -40
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/semaphore.rb +34 -13
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/thread_local_var.rb +8 -8
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic_reference/mutex_atomic.rb +3 -8
- data/lib/{concurrent → concurrent-ruby/concurrent}/atomic_reference/numeric_cas_wrapper.rb +1 -1
- data/lib/concurrent-ruby/concurrent/atomics.rb +10 -0
- data/lib/concurrent-ruby/concurrent/collection/lock_free_stack.rb +158 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/atomic_reference_map_backend.rb +3 -3
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/mri_map_backend.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/non_concurrent_map_backend.rb +1 -2
- data/lib/concurrent-ruby/concurrent/collection/map/truffleruby_map_backend.rb +14 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/non_concurrent_priority_queue.rb +30 -30
- data/lib/{concurrent → concurrent-ruby/concurrent}/collection/ruby_non_concurrent_priority_queue.rb +11 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/concern/dereferenceable.rb +3 -3
- data/lib/{concurrent → concurrent-ruby/concurrent}/concern/logging.rb +6 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/concern/observable.rb +7 -7
- data/lib/concurrent-ruby/concurrent/concurrent_ruby.jar +0 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/configuration.rb +15 -15
- data/lib/{concurrent → concurrent-ruby/concurrent}/constants.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/dataflow.rb +2 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/delay.rb +9 -7
- data/lib/{concurrent → concurrent-ruby/concurrent}/exchanger.rb +21 -25
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/abstract_executor_service.rb +35 -38
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/cached_thread_pool.rb +5 -5
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/executor_service.rb +17 -17
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/fixed_thread_pool.rb +47 -33
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_executor_service.rb +20 -17
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_single_thread_executor.rb +4 -3
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/java_thread_pool_executor.rb +29 -9
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_executor_service.rb +10 -6
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_single_thread_executor.rb +0 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/ruby_thread_pool_executor.rb +46 -42
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/safe_task_executor.rb +5 -5
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/simple_executor_service.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/single_thread_executor.rb +3 -2
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/thread_pool_executor.rb +7 -6
- data/lib/{concurrent → concurrent-ruby/concurrent}/executor/timer_set.rb +14 -17
- data/lib/{concurrent → concurrent-ruby/concurrent}/future.rb +4 -1
- data/lib/concurrent-ruby/concurrent/hash.rb +59 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/immutable_struct.rb +9 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/ivar.rb +5 -6
- data/lib/concurrent-ruby/concurrent/map.rb +346 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/maybe.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/mutable_struct.rb +27 -16
- data/lib/{concurrent → concurrent-ruby/concurrent}/mvar.rb +2 -2
- data/lib/{concurrent → concurrent-ruby/concurrent}/promise.rb +54 -21
- data/lib/concurrent-ruby/concurrent/promises.rb +2167 -0
- data/lib/concurrent-ruby/concurrent/re_include.rb +58 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/scheduled_task.rb +29 -16
- data/lib/concurrent-ruby/concurrent/set.rb +74 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/settable_struct.rb +12 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_lockable_object.rb +5 -5
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_struct.rb +18 -4
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/condition.rb +2 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/jruby_object.rb +1 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/lock.rb +2 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/lockable_object.rb +8 -10
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/mri_object.rb +1 -0
- data/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb +88 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/object.rb +53 -23
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/rbx_lockable_object.rb +6 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/rbx_object.rb +1 -0
- data/lib/concurrent-ruby/concurrent/synchronization/truffleruby_object.rb +47 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/volatile.rb +11 -9
- data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization.rb +4 -5
- data/lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb +88 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/thread_safe/util/striped64.rb +9 -4
- data/lib/{concurrent → concurrent-ruby/concurrent}/timer_task.rb +15 -35
- data/lib/{concurrent → concurrent-ruby/concurrent}/tuple.rb +1 -1
- data/lib/{concurrent → concurrent-ruby/concurrent}/tvar.rb +21 -58
- data/lib/{concurrent → concurrent-ruby/concurrent}/utility/engine.rb +4 -4
- data/lib/concurrent-ruby/concurrent/utility/monotonic_time.rb +90 -0
- data/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb +79 -0
- data/lib/{concurrent → concurrent-ruby/concurrent}/utility/processor_counter.rb +5 -35
- data/lib/concurrent-ruby/concurrent/version.rb +3 -0
- data/lib/concurrent-ruby/concurrent-ruby.rb +5 -0
- data/lib/{concurrent.rb → concurrent-ruby/concurrent.rb} +24 -20
- metadata +149 -134
- data/lib/concurrent/array.rb +0 -39
- data/lib/concurrent/atomic/atomic_reference.rb +0 -51
- data/lib/concurrent/atomic_reference/concurrent_update_error.rb +0 -8
- data/lib/concurrent/atomic_reference/direct_update.rb +0 -81
- data/lib/concurrent/atomic_reference/jruby+truffle.rb +0 -2
- data/lib/concurrent/atomic_reference/jruby.rb +0 -16
- data/lib/concurrent/atomic_reference/rbx.rb +0 -22
- data/lib/concurrent/atomic_reference/ruby.rb +0 -32
- data/lib/concurrent/atomics.rb +0 -53
- data/lib/concurrent/edge.rb +0 -26
- data/lib/concurrent/hash.rb +0 -36
- data/lib/concurrent/lazy_register.rb +0 -81
- data/lib/concurrent/map.rb +0 -240
- data/lib/concurrent/synchronization/mri_lockable_object.rb +0 -71
- data/lib/concurrent/synchronization/truffle_lockable_object.rb +0 -9
- data/lib/concurrent/synchronization/truffle_object.rb +0 -31
- data/lib/concurrent/thread_safe/util/array_hash_rbx.rb +0 -30
- data/lib/concurrent/utility/at_exit.rb +0 -97
- data/lib/concurrent/utility/monotonic_time.rb +0 -58
- data/lib/concurrent/utility/native_extension_loader.rb +0 -73
- data/lib/concurrent/version.rb +0 -4
- /data/lib/{concurrent → concurrent-ruby/concurrent}/atomic/abstract_thread_local_var.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_fixnum.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/map/synchronized_map_backend.rb +0 -0
- /data/lib/{concurrent → concurrent-ruby/concurrent}/concern/deprecation.rb +0 -0
- /data/lib/{concurrent → concurrent-ruby/concurrent}/concern/obligation.rb +0 -0
- /data/lib/{concurrent → concurrent-ruby/concurrent}/errors.rb +0 -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/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}/executors.rb +0 -0
- /data/lib/{concurrent → concurrent-ruby/concurrent}/options.rb +0 -0
- /data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/abstract_object.rb +0 -0
- /data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/jruby_lockable_object.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/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/power_of_two_tuple.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}/thread_safe/util.rb +0 -0
- /data/lib/{concurrent → concurrent-ruby/concurrent}/utility/native_integer.rb +0 -0
@@ -1,71 +0,0 @@
|
|
1
|
-
module Concurrent
|
2
|
-
module Synchronization
|
3
|
-
|
4
|
-
# @!visibility private
|
5
|
-
# @!macro internal_implementation_note
|
6
|
-
class MriLockableObject < AbstractLockableObject
|
7
|
-
protected
|
8
|
-
|
9
|
-
def ns_signal
|
10
|
-
@__condition__.signal
|
11
|
-
self
|
12
|
-
end
|
13
|
-
|
14
|
-
def ns_broadcast
|
15
|
-
@__condition__.broadcast
|
16
|
-
self
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
# @!visibility private
|
22
|
-
# @!macro internal_implementation_note
|
23
|
-
class MriMutexLockableObject < MriLockableObject
|
24
|
-
safe_initialization!
|
25
|
-
|
26
|
-
def initialize(*defaults)
|
27
|
-
super(*defaults)
|
28
|
-
@__lock__ = ::Mutex.new
|
29
|
-
@__condition__ = ::ConditionVariable.new
|
30
|
-
end
|
31
|
-
|
32
|
-
protected
|
33
|
-
|
34
|
-
def synchronize
|
35
|
-
if @__lock__.owned?
|
36
|
-
yield
|
37
|
-
else
|
38
|
-
@__lock__.synchronize { yield }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def ns_wait(timeout = nil)
|
43
|
-
@__condition__.wait @__lock__, timeout
|
44
|
-
self
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# @!visibility private
|
49
|
-
# @!macro internal_implementation_note
|
50
|
-
class MriMonitorLockableObject < MriLockableObject
|
51
|
-
safe_initialization!
|
52
|
-
|
53
|
-
def initialize(*defaults)
|
54
|
-
super(*defaults)
|
55
|
-
@__lock__ = ::Monitor.new
|
56
|
-
@__condition__ = @__lock__.new_cond
|
57
|
-
end
|
58
|
-
|
59
|
-
protected
|
60
|
-
|
61
|
-
def synchronize # TODO may be a problem with lock.synchronize { lock.wait }
|
62
|
-
@__lock__.synchronize { yield }
|
63
|
-
end
|
64
|
-
|
65
|
-
def ns_wait(timeout = nil)
|
66
|
-
@__condition__.wait timeout
|
67
|
-
self
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Concurrent
|
2
|
-
module Synchronization
|
3
|
-
|
4
|
-
module TruffleAttrVolatile
|
5
|
-
def self.included(base)
|
6
|
-
base.extend(ClassMethods)
|
7
|
-
end
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
def attr_volatile(*names)
|
11
|
-
# TODO may not always be available
|
12
|
-
attr_atomic(*names)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def full_memory_barrier
|
17
|
-
Truffle::System.full_memory_barrier
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# @!visibility private
|
22
|
-
# @!macro internal_implementation_note
|
23
|
-
class TruffleObject < AbstractObject
|
24
|
-
include TruffleAttrVolatile
|
25
|
-
|
26
|
-
def initialize
|
27
|
-
# nothing to do
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'concurrent/thread_safe/util'
|
2
|
-
|
3
|
-
module Concurrent
|
4
|
-
module ThreadSafe
|
5
|
-
module Util
|
6
|
-
def self.make_synchronized_on_rbx(klass)
|
7
|
-
klass.class_eval do
|
8
|
-
private
|
9
|
-
def _mon_initialize
|
10
|
-
@_monitor = Monitor.new unless @_monitor # avoid double initialisation
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.allocate
|
14
|
-
obj = super
|
15
|
-
obj.send(:_mon_initialize)
|
16
|
-
obj
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
klass.superclass.instance_methods(false).each do |method|
|
21
|
-
klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
22
|
-
def #{method}(*args)
|
23
|
-
@_monitor.synchronize { super }
|
24
|
-
end
|
25
|
-
RUBY
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'concurrent/synchronization'
|
3
|
-
|
4
|
-
module Concurrent
|
5
|
-
|
6
|
-
# Provides ability to add and remove handlers to be run at `Kernel#at_exit`, order is undefined.
|
7
|
-
# Each handler is executed at most once.
|
8
|
-
#
|
9
|
-
# @!visibility private
|
10
|
-
class AtExitImplementation < Synchronization::LockableObject
|
11
|
-
include Logger::Severity
|
12
|
-
|
13
|
-
def initialize(*args)
|
14
|
-
super()
|
15
|
-
synchronize { ns_initialize(*args) }
|
16
|
-
end
|
17
|
-
|
18
|
-
# Add a handler to be run at `Kernel#at_exit`
|
19
|
-
# @param [Object] handler_id optionally provide an id, if allready present, handler is replaced
|
20
|
-
# @yield the handler
|
21
|
-
# @return id of the handler
|
22
|
-
def add(handler_id = nil, &handler)
|
23
|
-
id = handler_id || handler.object_id
|
24
|
-
synchronize { @handlers[id] = handler }
|
25
|
-
id
|
26
|
-
end
|
27
|
-
|
28
|
-
# Delete a handler by handler_id
|
29
|
-
# @return [true, false]
|
30
|
-
def delete(handler_id)
|
31
|
-
!!synchronize { @handlers.delete handler_id }
|
32
|
-
end
|
33
|
-
|
34
|
-
# Is handler with handler_id rpesent?
|
35
|
-
# @return [true, false]
|
36
|
-
def handler?(handler_id)
|
37
|
-
synchronize { @handlers.key? handler_id }
|
38
|
-
end
|
39
|
-
|
40
|
-
# @return copy of the handlers
|
41
|
-
def handlers
|
42
|
-
synchronize { @handlers }.clone
|
43
|
-
end
|
44
|
-
|
45
|
-
# install `Kernel#at_exit` callback to execute added handlers
|
46
|
-
def install
|
47
|
-
synchronize do
|
48
|
-
@installed ||= begin
|
49
|
-
at_exit { runner }
|
50
|
-
true
|
51
|
-
end
|
52
|
-
self
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Will it run during `Kernel#at_exit`
|
57
|
-
def enabled?
|
58
|
-
synchronize { @enabled }
|
59
|
-
end
|
60
|
-
|
61
|
-
# Configure if it runs during `Kernel#at_exit`
|
62
|
-
def enabled=(value)
|
63
|
-
synchronize { @enabled = value }
|
64
|
-
end
|
65
|
-
|
66
|
-
# run the handlers manually
|
67
|
-
# @return ids of the handlers
|
68
|
-
def run
|
69
|
-
handlers, _ = synchronize { handlers, @handlers = @handlers, {} }
|
70
|
-
handlers.each do |_, handler|
|
71
|
-
begin
|
72
|
-
handler.call
|
73
|
-
rescue => error
|
74
|
-
Concurrent.global_logger.call(ERROR, error)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
handlers.keys
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def ns_initialize(enabled = true)
|
83
|
-
@handlers = {}
|
84
|
-
@enabled = enabled
|
85
|
-
end
|
86
|
-
|
87
|
-
def runner
|
88
|
-
run if synchronize { @enabled }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
private_constant :AtExitImplementation
|
93
|
-
|
94
|
-
# @see AtExitImplementation
|
95
|
-
# @!visibility private
|
96
|
-
AtExit = AtExitImplementation.new.install
|
97
|
-
end
|
@@ -1,58 +0,0 @@
|
|
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 [attach] monotonic_get_time
|
46
|
-
#
|
47
|
-
# Returns the current time a tracked by the application monotonic clock.
|
48
|
-
#
|
49
|
-
# @return [Float] The current monotonic time when `since` not given else
|
50
|
-
# the elapsed monotonic time between `since` and the current time
|
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
|
@@ -1,73 +0,0 @@
|
|
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
|
-
@c_extensions_loaded ||= false
|
16
|
-
end
|
17
|
-
|
18
|
-
def java_extensions_loaded?
|
19
|
-
@java_extensions_loaded ||= false
|
20
|
-
end
|
21
|
-
|
22
|
-
def set_c_extensions_loaded
|
23
|
-
@c_extensions_loaded = true
|
24
|
-
end
|
25
|
-
|
26
|
-
def set_java_extensions_loaded
|
27
|
-
@java_extensions_loaded = true
|
28
|
-
end
|
29
|
-
|
30
|
-
def load_native_extensions
|
31
|
-
unless defined? Synchronization::AbstractObject
|
32
|
-
raise 'native_extension_loader loaded before Synchronization::AbstractObject'
|
33
|
-
end
|
34
|
-
|
35
|
-
if Concurrent.on_cruby? && !c_extensions_loaded?
|
36
|
-
tries = [
|
37
|
-
lambda do
|
38
|
-
require 'concurrent/extension'
|
39
|
-
set_c_extensions_loaded
|
40
|
-
end,
|
41
|
-
lambda do
|
42
|
-
# may be a Windows cross-compiled native gem
|
43
|
-
require "concurrent/#{RUBY_VERSION[0..2]}/extension"
|
44
|
-
set_c_extensions_loaded
|
45
|
-
end]
|
46
|
-
|
47
|
-
tries.each do |try|
|
48
|
-
begin
|
49
|
-
try.call
|
50
|
-
break
|
51
|
-
rescue LoadError
|
52
|
-
next
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
if Concurrent.on_jruby? && !java_extensions_loaded?
|
58
|
-
begin
|
59
|
-
require 'concurrent_ruby_ext'
|
60
|
-
set_java_extensions_loaded
|
61
|
-
rescue LoadError
|
62
|
-
# move on with pure-Ruby implementations
|
63
|
-
raise 'On JRuby but Java extensions failed to load.'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# @!visibility private
|
71
|
-
extend Utility::NativeExtensionLoader
|
72
|
-
end
|
73
|
-
|
data/lib/concurrent/version.rb
DELETED
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
|
/data/lib/{concurrent → concurrent-ruby/concurrent}/collection/copy_on_write_observer_set.rb
RENAMED
File without changes
|
/data/lib/{concurrent → concurrent-ruby/concurrent}/collection/java_non_concurrent_priority_queue.rb
RENAMED
File without changes
|
/data/lib/{concurrent → concurrent-ruby/concurrent}/collection/map/synchronized_map_backend.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/data/lib/{concurrent → concurrent-ruby/concurrent}/executor/serialized_execution_delegator.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/data/lib/{concurrent → concurrent-ruby/concurrent}/synchronization/jruby_lockable_object.rb
RENAMED
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
|