Sha256: ca1b58105c77fc66dea820700ae8b969d06e6a1a700fbf393c183468ec98b418

Contents?: true

Size: 1.7 KB

Versions: 83

Compression:

Stored size: 1.7 KB

Contents

require 'concurrent/utility/engine'

module Concurrent

  module Utility

    # @!visibility private
    module NativeExtensionLoader

      def allow_c_extensions?
        Concurrent.on_cruby?
      end

      def c_extensions_loaded?
        @c_extensions_loaded ||= false
      end

      def java_extensions_loaded?
        @java_extensions_loaded ||= false
      end

      def set_c_extensions_loaded
        @c_extensions_loaded = true
      end

      def set_java_extensions_loaded
        @java_extensions_loaded = true
      end

      def load_native_extensions
        unless defined? Synchronization::AbstractObject
          raise 'native_extension_loader loaded before Synchronization::AbstractObject'
        end

        if Concurrent.on_cruby? && !c_extensions_loaded?
          tries = [
            lambda do
              require 'concurrent/extension'
              set_c_extensions_loaded
            end,
            lambda do
              # may be a Windows cross-compiled native gem
              require "concurrent/#{RUBY_VERSION[0..2]}/extension"
              set_c_extensions_loaded
            end]

          tries.each do |try|
            begin
              try.call
              break
            rescue LoadError
              next
            end
          end
        end

        if Concurrent.on_jruby? && !java_extensions_loaded?
          begin
            require 'concurrent_ruby_ext'
            set_java_extensions_loaded
          rescue LoadError
            # move on with pure-Ruby implementations
            raise 'On JRuby but Java extensions failed to load.'
          end
        end
      end
    end
  end

  # @!visibility private
  extend Utility::NativeExtensionLoader
end

Version data entries

83 entries across 77 versions & 22 rubygems

Version Path
tdiary-5.0.2 vendor/bundle/gems/concurrent-ruby-1.0.2/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-base64-1.0.2 vendor/bundle/jruby/2.3.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-base64-1.0.1 vendor/bundle/jruby/2.3.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-base64-1.0.0 vendor/bundle/jruby/2.3.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
tdiary-5.0.1 vendor/bundle/gems/concurrent-ruby-1.0.2/lib/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.0.3.pre3-java lib/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.0.3.pre3 lib/concurrent/utility/native_extension_loader.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.2/lib/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.0.2-java lib/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.0.2 lib/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.0.1-java lib/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.0.1 lib/concurrent/utility/native_extension_loader.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/utility/native_extension_loader.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/concurrent-ruby-1.0.0/lib/concurrent/utility/native_extension_loader.rb
concurrent-ruby-1.0.0-java lib/concurrent/utility/native_extension_loader.rb