Module: IO::Event::Selector
- Defined in:
- lib/io/event/selector.rb,
lib/io/event/selector/select.rb,
lib/io/event/selector/nonblock.rb,
ext/io/event/event.c
Defined Under Namespace
Classes: EPoll, KQueue, Select, URing
Class Method Summary collapse
-
.default(env = ENV) ⇒ Object
The default selector implementation, which is chosen based on the environment and available implementations.
-
.new(loop, env = ENV) ⇒ Object
Create a new selector instance, according to the best available implementation.
-
.nonblock(io) ⇒ Object
Execute the given block in non-blocking mode.
Class Method Details
.default(env = ENV) ⇒ Object
The default selector implementation, which is chosen based on the environment and available implementations.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/io/event/selector.rb', line 16 def self.default(env = ENV) if name = env["IO_EVENT_SELECTOR"]&.to_sym return const_get(name) end if self.const_defined?(:URing) URing elsif self.const_defined?(:EPoll) EPoll elsif self.const_defined?(:KQueue) KQueue else Select end end |
.new(loop, env = ENV) ⇒ Object
Create a new selector instance, according to the best available implementation.
37 38 39 40 41 42 43 44 45 |
# File 'lib/io/event/selector.rb', line 37 def self.new(loop, env = ENV) selector = default(env).new(loop) if debug = env["IO_EVENT_DEBUG_SELECTOR"] selector = Debug::Selector.wrap(selector, env) end return selector end |
.nonblock(io) ⇒ Object
Execute the given block in non-blocking mode.
14 15 16 17 18 19 |
# File 'lib/io/event/selector/nonblock.rb', line 14 def self.nonblock(io, &block) io.nonblock(&block) rescue Errno::EBADF # Windows. yield end |