Sha256: 13e69be10ba4d1671da44f5710e905f903bb2869ab66bd13a23473b013d06bca

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require "socket"
require "nio/version"

# New I/O for Ruby
module NIO
  # NIO implementation, one of the following (as a string):
  # * select: in pure Ruby using Kernel.select
  # * libev: as a C extension using libev
  # * java: using Java NIO
  def self.engine
    ENGINE
  end

  def self.pure?(env = ENV)
    # The user has explicitly opted in to non-native implementation:
    if env["NIO4R_PURE"] == "true"
      return true
    end

    # Native Ruby on Windows is not supported:
    if (Gem.win_platform? && !defined?(JRUBY_VERSION))
      return true
    end

    # M1 native extension is crashing on M1 (arm64):
    # if RUBY_PLATFORM =~ /darwin/ && RUBY_PLATFORM =~ /arm64/
    #   return true
    # end

    return false
  end
end

if NIO.pure?
  require "nio/monitor"
  require "nio/selector"
  require "nio/bytebuffer"
  NIO::ENGINE = "ruby"
else
  require "nio4r_ext"

  if defined?(JRUBY_VERSION)
    require "java"
    require "jruby"
    org.nio4r.Nio4r.new.load(JRuby.runtime, false)
    NIO::ENGINE = "java"
  else
    NIO::ENGINE = "libev"
  end
end

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/nio4r-2.5.8/lib/nio.rb
nio4r-2.6.0-java lib/nio.rb
nio4r-2.6.0 lib/nio.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/nio4r-2.5.8/lib/nio.rb
nio4r-2.5.9-java lib/nio.rb
nio4r-2.5.9 lib/nio.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/nio4r-2.5.8/lib/nio.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/nio4r-2.5.8/lib/nio.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/nio4r-2.5.7/lib/nio.rb
nio4r-2.5.8-java lib/nio.rb
nio4r-2.5.8 lib/nio.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/nio4r-2.5.7/lib/nio.rb
nio4r-2.5.7-java lib/nio.rb
nio4r-2.5.7 lib/nio.rb