Skip to content

Commit 6beb332

Browse files
committed
RUBY_ENGINE is always defined
1 parent 7d9c108 commit 6beb332

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

examples/benchmark_read_write_lock.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
end.parse!
3535

3636
def jruby?
37-
defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
37+
RUBY_ENGINE == "jruby"
3838
end
3939

4040
# for performance comparison with ReadWriteLock

lib/concurrent-ruby/concurrent/thread_safe/util/cheap_lockable.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ module Util
3232
# @!visibility private
3333
module CheapLockable
3434
private
35-
engine = defined?(RUBY_ENGINE) && RUBY_ENGINE
36-
if engine == 'rbx'
35+
if Concurrent.on_rbx?
3736
# Making use of the Rubinius' ability to lock via object headers to avoid the overhead of the extra Mutex objects.
3837
def cheap_synchronize
3938
Rubinius.lock(self)
@@ -70,7 +69,7 @@ def cheap_broadcast
7069
waiters.shift << true until waiters.empty?
7170
self
7271
end
73-
elsif engine == 'jruby'
72+
elsif Concurrent.on_jruby?
7473
# Use Java's native synchronized (this) { wait(); notifyAll(); } to avoid the overhead of the extra Mutex objects
7574
require 'jruby'
7675

lib/concurrent-ruby/concurrent/utility/engine.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ module Utility
44
# @!visibility private
55
module EngineDetector
66
def on_jruby?
7-
ruby_engine == 'jruby'
7+
RUBY_ENGINE == 'jruby'
88
end
99

1010
def on_jruby_9000?
1111
on_jruby? && ruby_version(JRUBY_VERSION, :>=, 9, 0, 0)
1212
end
1313

1414
def on_cruby?
15-
ruby_engine == 'ruby'
15+
RUBY_ENGINE == 'ruby'
1616
end
1717

1818
def on_rbx?
19-
ruby_engine == 'rbx'
19+
RUBY_ENGINE == 'rbx'
2020
end
2121

2222
def on_truffleruby?
23-
ruby_engine == 'truffleruby'
23+
RUBY_ENGINE == 'truffleruby'
2424
end
2525

2626
def on_windows?
@@ -35,10 +35,6 @@ def on_linux?
3535
!(RbConfig::CONFIG['host_os'] =~ /linux/).nil?
3636
end
3737

38-
def ruby_engine
39-
defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
40-
end
41-
4238
def ruby_version(version = RUBY_VERSION, comparison, major, minor, patch)
4339
result = (version.split('.').map(&:to_i) <=> [major, minor, patch])
4440
comparisons = { :== => [0],

0 commit comments

Comments
 (0)