Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update engine detection #719

Merged
merged 3 commits into from May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -5,7 +5,7 @@
when Concurrent.on_cruby?
require 'gvl_future'
GVLFuture
when Concurrent.on_rbx? || Concurrent.on_truffle?
when Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'rbx_future'
RBXFuture
when Concurrent.on_jruby?
Expand Down
Expand Up @@ -5,7 +5,7 @@
when Concurrent.on_cruby?
require 'gvl_future'
GVLFuture
when Concurrent.on_rbx? || Concurrent.on_truffle?
when Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'rbx_future'
RBXFuture
when Concurrent.on_jruby?
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/futures-rubyconf2015/benchmarks/special-new.rb
Expand Up @@ -5,7 +5,7 @@
when Concurrent.on_cruby?
require 'gvl_future'
GVLFuture
when Concurrent.on_rbx? || Concurrent.on_truffle?
when Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'rbx_future'
RBXFuture
when Concurrent.on_jruby?
Expand Down
Expand Up @@ -5,7 +5,7 @@
when Concurrent.on_cruby?
require 'gvl_future'
GVLFuture
when Concurrent.on_rbx? || Concurrent.on_truffle?
when Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'rbx_future'
RBXFuture
when Concurrent.on_jruby?
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/array.rb
Expand Up @@ -32,7 +32,7 @@ class Array < ::Array
include JRuby::Synchronized
end

elsif Concurrent.on_rbx? || Concurrent.on_truffle?
elsif Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'monitor'
require 'concurrent/thread_safe/util/array_hash_rbx'

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/hash.rb
Expand Up @@ -23,7 +23,7 @@ class Hash < ::Hash
include JRuby::Synchronized
end

elsif Concurrent.on_rbx? || Concurrent.on_truffle?
elsif Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'monitor'
require 'concurrent/thread_safe/util/array_hash_rbx'

Expand Down
30 changes: 12 additions & 18 deletions lib/concurrent/map.rb
@@ -1,33 +1,27 @@
require 'thread'
require 'concurrent/constants'
require 'concurrent/synchronization'
require 'concurrent/utility/engine'

module Concurrent
# @!visibility private
module Collection

# @!visibility private
MapImplementation = if Concurrent.java_extensions_loaded?
MapImplementation = case
when Concurrent.on_jruby?
# noinspection RubyResolve
JRubyMapBackend
elsif defined?(RUBY_ENGINE)
case RUBY_ENGINE
when 'ruby'
require 'concurrent/collection/map/mri_map_backend'
MriMapBackend
when 'rbx'
require 'concurrent/collection/map/atomic_reference_map_backend'
AtomicReferenceMapBackend
when 'jruby+truffle'
require 'concurrent/collection/map/atomic_reference_map_backend'
AtomicReferenceMapBackend
else
warn 'Concurrent::Map: unsupported Ruby engine, using a fully synchronized Concurrent::Map implementation' if $VERBOSE
require 'concurrent/collection/map/synchronized_map_backend'
SynchronizedMapBackend
end
else
when Concurrent.on_cruby?
require 'concurrent/collection/map/mri_map_backend'
MriMapBackend
when Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'concurrent/collection/map/atomic_reference_map_backend'
AtomicReferenceMapBackend
else
warn 'Concurrent::Map: unsupported Ruby engine, using a fully synchronized Concurrent::Map implementation'
require 'concurrent/collection/map/synchronized_map_backend'
SynchronizedMapBackend
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/set.rb
Expand Up @@ -33,7 +33,7 @@ class Set < ::Set
include JRuby::Synchronized
end

elsif Concurrent.on_rbx? || Concurrent.on_truffle?
elsif Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'monitor'
require 'concurrent/thread_safe/util/array_hash_rbx'

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/synchronization/lockable_object.rb
Expand Up @@ -12,7 +12,7 @@ module Synchronization
JRubyLockableObject
when Concurrent.on_rbx?
RbxLockableObject
when Concurrent.on_truffle?
when Concurrent.on_truffleruby?
MriMutexLockableObject
else
warn 'Possibly unsupported Ruby implementation'
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/synchronization/object.rb
Expand Up @@ -10,7 +10,7 @@ module Synchronization
JRubyObject
when Concurrent.on_rbx?
RbxObject
when Concurrent.on_truffle?
when Concurrent.on_truffleruby?
TruffleObject
else
MriObject
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/synchronization/volatile.rb
Expand Up @@ -25,7 +25,7 @@ module Synchronization
MriAttrVolatile
when Concurrent.on_jruby?
JRubyAttrVolatile
when Concurrent.on_rbx? || Concurrent.on_truffle?
when Concurrent.on_rbx? || Concurrent.on_truffleruby?
RbxAttrVolatile
else
MriAttrVolatile
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/utility/engine.rb
Expand Up @@ -19,7 +19,7 @@ def on_rbx?
ruby_engine == 'rbx'
end

def on_truffle?
def on_truffleruby?
ruby_engine == 'truffleruby'
end

Expand Down
2 changes: 0 additions & 2 deletions lib/concurrent/utility/processor_counter.rb
Expand Up @@ -76,8 +76,6 @@ def physical_processor_count
def compute_processor_count
if Concurrent.on_jruby?
java.lang.Runtime.getRuntime.availableProcessors
elsif Concurrent.on_truffle?
Truffle::Primitive.logical_processors
else
os_name = RbConfig::CONFIG["target_os"]
if os_name =~ /mingw|mswin/
Expand Down