Module: NIO

Defined in:
lib/nio.rb,
lib/nio/monitor.rb,
lib/nio/version.rb,
lib/nio/selector.rb,
lib/nio/bytebuffer.rb,
ext/nio4r/monitor.c,
ext/nio4r/selector.c,
ext/nio4r/bytebuffer.c

Overview

New I/O for Ruby

Defined Under Namespace

Classes: ByteBuffer, Monitor, Selector

Constant Summary collapse

ENGINE =
"libev"
VERSION =
"2.5.8"

Class Method Summary collapse

Class Method Details

.engineObject

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



12
13
14
# File 'lib/nio.rb', line 12

def self.engine
  ENGINE
end

.pure?(env = ENV) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/nio.rb', line 16

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