Skip to content

Commit

Permalink
Be more explicit with why pure? is being used.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Feb 5, 2021
1 parent 4338c5d commit 41469f6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/nio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,28 @@ module 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 ENV["NIO4R_PURE"] == "true" || (Gem.win_platform? && !defined?(JRUBY_VERSION)) || (RUBY_PLATFORM =~ /darwin/ && RUBY_PLATFORM =~ /arm64/)
if NIO.pure?
require "nio/monitor"
require "nio/selector"
require "nio/bytebuffer"
Expand Down

0 comments on commit 41469f6

Please sign in to comment.