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

Released under the MIT License. Copyright, 2016, by Upekshe Jayasekera. Copyright, 2016-2017, by Tony Arcieri. Copyright, 2020, by Thomas Dziedzic. Copyright, 2023, by Samuel Williams.

Defined Under Namespace

Classes: ByteBuffer, Monitor, Selector

Constant Summary collapse

ENGINE =
"libev"
VERSION =
"2.7.4"

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



21
22
23
# File 'lib/nio.rb', line 21

def self.engine
  ENGINE
end

.pure?(env = ENV) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/nio.rb', line 25

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