Skip to content

Commit

Permalink
Avoid using blocking IO.select.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 23, 2021
1 parent 7aa6186 commit de94746
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/reline/ansi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,7 @@ def self.empty_buffer?
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)
Expand All @@ -197,8 +192,7 @@ def self.ungetc(c)

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)
Expand Down

0 comments on commit de94746

Please sign in to comment.