Sha256: f04529e10979d1fb21baad88d8f5d4837774c88f70421d7cac5328b6b27e9ed7
Contents?: true
Size: 1.21 KB
Versions: 14
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require 'polyphony' if Object.constants.include?(:Reline) class Reline::ANSI def self.select(read_ios = [], write_ios = [], error_ios = [], timeout = nil) p [:select, read_ios] raise if read_ios.size > 1 raise if write_ios.size > 0 raise if error_ios.size > 0 fiber = Fiber.current timer = spin do sleep timeout fiber.cancel end read_ios.each do |io| Thread.current.agent.wait_io(io, false) return [io] end rescue Polyphony::Cancel return nil ensure timer.stop end end else # readline blocks the current thread, so we offload it to the blocking-ops # thread pool. That way, the reactor loop can keep running while waiting for # readline to return module ::Readline alias_method :orig_readline, :readline Workers = Polyphony::ThreadPool.new def readline(*args) p :readline # caller.each do |l| # STDOUT.orig_puts l # end Workers.process { orig_readline(*args) } end end # RubyLex patches class ::RubyLex class TerminateLineInput2 < RuntimeError end const_set(:TerminateLineInput, TerminateLineInput2) end end
Version data entries
14 entries across 14 versions & 1 rubygems