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

Use supported TruffleRuby APIs #765

Merged
merged 2 commits into from Oct 10, 2018
Jump to file or symbol
Failed to load files and symbols.
+21 −3
Diff settings

Always

Just for now

Next

Use supported TruffleRuby APIs

  • Loading branch information...
chrisseaton committed Oct 9, 2018
commit 8de7cbd044531db1337dd20b876151f208a25e84
View
@@ -6,6 +6,7 @@ concurrent-ruby:
* fixed documentation and README links
* fix Set for TruffleRuby and Rubinius
* use properly supported TruffleRuby APIs
concurrent-ruby-edge:
@@ -2,6 +2,13 @@
require 'concurrent/utility/engine'
require 'concurrent/atomic_reference/numeric_cas_wrapper'
# Shim for TruffleRuby::AtomicReference
if Concurrent.on_truffleruby? && !defined?(TruffleRuby::AtomicReference)
module TruffleRuby
AtomicReference = Truffle::AtomicReference
end
end
module Concurrent
# Define update methods that use direct paths
@@ -155,8 +162,10 @@ class JavaAtomicReference
end
JavaAtomicReference
when Concurrent.on_truffleruby?
class TruffleRubyAtomicReference < Truffle::AtomicReference
class TruffleRubyAtomicReference < TruffleRuby::AtomicReference
include AtomicDirectUpdate
alias_method :value, :get
alias_method :value=, :set
alias_method :compare_and_swap, :compare_and_set
alias_method :swap, :get_and_set
end
@@ -1,5 +1,14 @@
require 'concurrent/thread_safe/util'
# Shim for TruffleRuby.synchronized
if Concurrent.on_truffleruby? && !TruffleRuby.respond_to?(:synchronized)
module TruffleRuby
def self.synchronized(object, &block)
Truffle::System.synchronized(object, &block)
end
end
end
module Concurrent
module ThreadSafe
module Util
@@ -44,8 +53,7 @@ def self.make_synchronized_on_truffleruby(klass)
klass.superclass.instance_methods(false).each do |method|
klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{method}(*args, &block)
# TODO (pitr-ch 01-Jul-2018): don't use internal TruffleRuby APIs
Truffle::System.synchronized(self) { super(*args, &block) }
TruffleRuby.synchronized(self) { super(*args, &block) }
end
RUBY
end
ProTip! Use n and p to navigate between commits in a pull request.