Skip to content

Commit d50dfa5

Browse files
committed
initial support for jruby+truffle
1 parent 0dcb23d commit d50dfa5

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'concurrent/atomic_reference/rbx'

lib/concurrent/synchronization/lockable_object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Synchronization
1010
MriMutexLockableObject
1111
when Concurrent.on_jruby?
1212
JRubyLockableObject
13-
when Concurrent.on_rbx?
13+
when Concurrent.on_rbx? || Concurrent.on_truffle?
1414
RbxLockableObject
1515
else
1616
warn 'Possibly unsupported Ruby implementation'

lib/concurrent/synchronization/object.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ module Synchronization
88
MriObject
99
when Concurrent.on_jruby?
1010
JRubyObject
11-
when Concurrent.on_rbx?
11+
when Concurrent.on_rbx? || Concurrent.on_truffle?
1212
RbxObject
1313
else
14-
warn 'Possibly unsupported Ruby implementation'
1514
MriObject
1615
end
1716
private_constant :ObjectImplementation

lib/concurrent/synchronization/rbx_lockable_object.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ def synchronize(&block)
1818
if @__owner__ == Thread.current
1919
yield
2020
else
21-
Rubinius.lock(self)
22-
begin
21+
result = nil
22+
Rubinius.synchronize(self) do
2323
@__owner__ = Thread.current
24-
result = yield
25-
ensure
24+
result = yield
2625
@__owner__ = nil
27-
Rubinius.unlock(self)
28-
result
2926
end
27+
result
3028
end
3129
end
3230

lib/concurrent/utility/engine.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def on_rbx?
1919
ruby_engine == 'rbx'
2020
end
2121

22+
def on_truffle?
23+
ruby_engine == 'jruby+truffle'
24+
end
25+
2226
def on_windows?
2327
!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/).nil?
2428
end

0 commit comments

Comments
 (0)