Sha256: dd5dcb1e5386399670bfff1043af0e77f6015ccf6bb7d140a92dc9a7e0ff8eeb

Contents?: true

Size: 987 Bytes

Versions: 6505

Compression:

Stored size: 987 Bytes

Contents

# frozen_string_literal: true

require "socket"

module Byebug
  module Remote
    #
    # Server for remote debugging
    #
    class Server
      attr_reader :actual_port, :wait_connection

      def initialize(wait_connection:, &block)
        @thread = nil
        @wait_connection = wait_connection
        @main_loop = block
      end

      #
      # Start the remote debugging server
      #
      def start(host, port)
        return if @thread

        if wait_connection
          mutex = Mutex.new
          proceed = ConditionVariable.new
        end

        server = TCPServer.new(host, port)
        @actual_port = server.addr[1]

        yield if block_given?

        @thread = DebugThread.new do
          while (session = server.accept)
            @main_loop.call(session)

            mutex.synchronize { proceed.signal } if wait_connection
          end
        end

        mutex.synchronize { proceed.wait(mutex) } if wait_connection
      end
    end
  end
end

Version data entries

6,505 entries across 6,501 versions & 34 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_organization_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb
cybrid_api_id_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/remote/server.rb