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

Class Method Details

.default(env = ENV) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/io/event/selector.rb', line 12

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



28
29
30
31
32
33
34
35
36
# File 'lib/io/event/selector.rb', line 28

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



128
129
130
131
132
133
# File 'ext/io/event/selector/selector.c', line 128

def self.nonblock(io, &block)
	io.nonblock(&block)
rescue Errno::EBADF
	# Windows.
	yield
end