Sha256: 744644852c2345c38e7862b1c20d01e18a3aaa3bfe873f76de475c93ba1ae850

Contents?: true

Size: 1.91 KB

Versions: 103

Compression:

Stored size: 1.91 KB

Contents

require 'concurrent/utility/engine'
# Synchronization::AbstractObject must be defined before loading the extension
require 'concurrent/synchronization/abstract_object'

module Concurrent
  # @!visibility private
  module Utility
    # @!visibility private
    module NativeExtensionLoader

      def allow_c_extensions?
        Concurrent.on_cruby?
      end

      def c_extensions_loaded?
        defined?(@c_extensions_loaded) && @c_extensions_loaded
      end

      def load_native_extensions
        if Concurrent.on_cruby? && !c_extensions_loaded?
          ['concurrent/concurrent_ruby_ext',
           "concurrent/#{RUBY_VERSION[0..2]}/concurrent_ruby_ext"
          ].each { |p| try_load_c_extension p }
        end

        if Concurrent.on_jruby? && !java_extensions_loaded?
          begin
            require 'concurrent/concurrent_ruby.jar'
            set_java_extensions_loaded
          rescue LoadError => e
            raise e, "Java extensions are required for JRuby.\n" + e.message, e.backtrace
          end
        end
      end

      private

      def load_error_path(error)
        if error.respond_to? :path
          error.path
        else
          error.message.split(' -- ').last
        end
      end

      def set_c_extensions_loaded
        @c_extensions_loaded = true
      end

      def java_extensions_loaded?
        defined?(@java_extensions_loaded) && @java_extensions_loaded
      end

      def set_java_extensions_loaded
        @java_extensions_loaded = true
      end

      def try_load_c_extension(path)
        require path
        set_c_extensions_loaded
      rescue LoadError => e
        if load_error_path(e) == path
          # move on with pure-Ruby implementations
          # TODO (pitr-ch 12-Jul-2018): warning on verbose?
        else
          raise e
        end
      end

    end
  end

  # @!visibility private
  extend Utility::NativeExtensionLoader
end

Concurrent.load_native_extensions

Version data entries

103 entries across 103 versions & 16 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.3.4 lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.3.3 lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.3.2 lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.1/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.3.1 lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.3.1.pre lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.2.3 lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb