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
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
tdiary-5.0.11 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
sprokovuln-0.2.0 vendor/ruby/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.5-java/lib/concurrent/utility/native_extension_loader.rb
tdiary-5.0.9 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
monero_wallet_gen-0.1.0 vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
tdiary-5.0.8 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
tdiary-5.0.7 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
pract6-0.1.0 .gem/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb
tdiary-5.0.6 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.5-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.5-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.5-java/lib/concurrent/utility/native_extension_loader.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.0-java/lib/concurrent/utility/native_extension_loader.rb