1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Avoid using blocking IO.select.

https://github.com/ruby/reline/commit/de94746393
This commit is contained in:
Samuel Williams 2021-06-23 19:44:46 +12:00 committed by aycabta
parent d340b091a8
commit e788481843

View file

@ -183,12 +183,7 @@ class Reline::ANSI
unless @@buf.empty?
return false
end
rs, = IO.select([@@input], [], [], 0.00001)
if rs and rs[0]
false
else
true
end
!@@input.wait_readable(0)
end
def self.ungetc(c)
@ -197,8 +192,7 @@ class Reline::ANSI
def self.retrieve_keybuffer
begin
result = select([@@input], [], [], 0.001)
return if result.nil?
return unless @@input.wait_readable(0.001)
str = @@input.read_nonblock(1024)
str.bytes.each do |c|
@@buf.push(c)