Skip to content

Commit 90be641

Browse files
committed
Fix engine detection in Map
1 parent eca4cc0 commit 90be641

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

lib/concurrent/map.rb

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
11
require 'thread'
22
require 'concurrent/constants'
33
require 'concurrent/synchronization'
4+
require 'concurrent/utility/engine'
45

56
module Concurrent
67
# @!visibility private
78
module Collection
89

910
# @!visibility private
10-
MapImplementation = if Concurrent.java_extensions_loaded?
11+
MapImplementation = case
12+
when Concurrent.on_jruby?
1113
# noinspection RubyResolve
1214
JRubyMapBackend
13-
elsif defined?(RUBY_ENGINE)
14-
case RUBY_ENGINE
15-
when 'ruby'
16-
require 'concurrent/collection/map/mri_map_backend'
17-
MriMapBackend
18-
when 'rbx'
19-
require 'concurrent/collection/map/atomic_reference_map_backend'
20-
AtomicReferenceMapBackend
21-
when 'jruby+truffle'
22-
require 'concurrent/collection/map/atomic_reference_map_backend'
23-
AtomicReferenceMapBackend
24-
else
25-
warn 'Concurrent::Map: unsupported Ruby engine, using a fully synchronized Concurrent::Map implementation' if $VERBOSE
26-
require 'concurrent/collection/map/synchronized_map_backend'
27-
SynchronizedMapBackend
28-
end
29-
else
15+
when Concurrent.on_cruby?
16+
require 'concurrent/collection/map/mri_map_backend'
3017
MriMapBackend
18+
when Concurrent.on_rbx? || Concurrent.on_truffle?
19+
require 'concurrent/collection/map/atomic_reference_map_backend'
20+
AtomicReferenceMapBackend
21+
else
22+
warn 'Concurrent::Map: unsupported Ruby engine, using a fully synchronized Concurrent::Map implementation'
23+
require 'concurrent/collection/map/synchronized_map_backend'
24+
SynchronizedMapBackend
3125
end
3226
end
3327

0 commit comments

Comments
 (0)