Permalink
Browse files

Merge pull request #765 from ruby-concurrency/truffleruby-api

Use supported TruffleRuby APIs
  • Loading branch information...
pitr-ch committed Oct 10, 2018
2 parents e6da3dd + 5975961 commit 10ec86f71ed83d2f002e4bbcba5d97322d572bbb
Showing with 22 additions and 4 deletions.
  1. +1 −1 .travis.yml
  2. +1 −0 CHANGELOG.md
  3. +10 −1 lib/concurrent/atomic/atomic_reference.rb
  4. +10 −2 lib/concurrent/thread_safe/util/data_structures.rb
View
@@ -15,7 +15,7 @@ matrix:
- name: TruffleRuby Latest
rvm: system
install:
- export TRUFFLERUBY_VERSION=1.0.0-rc5
- export TRUFFLERUBY_VERSION=1.0.0-rc7
- curl -L https://github.com/oracle/truffleruby/releases/download/vm-$TRUFFLERUBY_VERSION/truffleruby-$TRUFFLERUBY_VERSION-linux-amd64.tar.gz | tar xz
- export PATH="$PWD/truffleruby-$TRUFFLERUBY_VERSION-linux-amd64/bin:$PATH"
- gem install bundler
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

0 comments on commit 10ec86f

Please sign in to comment.