Sha256: 1a893e39f3f9014abd897f830b4ca5c340093c9d31d965e9cc23909a825b28a1

Contents?: true

Size: 1.78 KB

Versions: 95

Compression:

Stored size: 1.78 KB

Contents

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
      def self.make_synchronized_on_rbx(klass)
        klass.class_eval do
          private

          def _mon_initialize
            @_monitor = Monitor.new unless @_monitor # avoid double initialisation
          end

          def self.new(*args)
            obj = super(*args)
            obj.send(:_mon_initialize)
            obj
          end
        end

        klass.superclass.instance_methods(false).each do |method|
          case method
          when :new_range, :new_reserved
            klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
              def #{method}(*args)
                obj = super
                obj.send(:_mon_initialize)
                obj
              end
            RUBY
          else
            klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
              def #{method}(*args)
                monitor = @_monitor
                monitor or raise("BUG: Internal monitor was not properly initialized. Please report this to the concurrent-ruby developers.")
                monitor.synchronize { super }
              end
            RUBY
          end
        end
      end

      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)    
              TruffleRuby.synchronized(self) { super(*args, &block) }
            end
          RUBY
        end
      end
    end
  end
end

Version data entries

95 entries across 83 versions & 18 rubygems

Version Path
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/thread_safe/util/data_structures.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.4/lib/concurrent/thread_safe/util/data_structures.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
spiral_form-0.1.1 vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
spiral_form-0.1.0 vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
ric-0.13.0 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/thread_safe/util/data_structures.rb