Skip to content

Commit 41469f6

Browse files
committed
Be more explicit with why pure? is being used.
1 parent 4338c5d commit 41469f6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lib/nio.rb

+20-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,28 @@ module NIO
1212
def self.engine
1313
ENGINE
1414
end
15+
16+
def self.pure?(env = ENV)
17+
# The user has explicitly opted in to non-native implementation:
18+
if env["NIO4R_PURE"] == "true"
19+
return true
20+
end
21+
22+
# Native Ruby on Windows is not supported:
23+
if (Gem.win_platform? && !defined?(JRUBY_VERSION))
24+
return true
25+
end
26+
27+
# M1 native extension is crashing on M1 (arm64):
28+
if RUBY_PLATFORM =~ /darwin/ && RUBY_PLATFORM =~ /arm64/
29+
return true
30+
end
31+
32+
return false
33+
end
1534
end
1635

17-
if ENV["NIO4R_PURE"] == "true" || (Gem.win_platform? && !defined?(JRUBY_VERSION)) || (RUBY_PLATFORM =~ /darwin/ && RUBY_PLATFORM =~ /arm64/)
36+
if NIO.pure?
1837
require "nio/monitor"
1938
require "nio/selector"
2039
require "nio/bytebuffer"

0 commit comments

Comments
 (0)