Sha256: 3284b3a9e2c8d1a3f34455260f00cdebb481caee64908c1251f97dd3c4b80eae

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

require 'thread'

module Debugger
  class Interface
  end

  class LocalInterface < Interface
  end


  class RemoteInterface < Interface # :nodoc:
    attr_accessor :command_queue

    def initialize(socket)
      @socket = socket
      @command_queue = Queue.new
    end
    
    def read_command
      result = non_blocking_gets
      raise IOError unless result
      result.chomp
    end

    def print(*args)
      @socket.printf(*args)
    end
    
    def close
      @socket.close
    rescue IOError, SystemCallError
    end

    # Workaround for JRuby issue http://jira.codehaus.org/browse/JRUBY-2063
    def non_blocking_gets
      loop do
        result, _, _ = IO.select( [@socket], nil, nil, 0.2 )
        next unless result
        return result[0].gets
      end
    end

  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-debug-ide22-0.7.4 lib/ruby-debug-ide/interface.rb