Sha256: 92c329d0ba2f315380694281edd00f321004ed363b834d5114a21e65b6edf6b9

Contents?: true

Size: 488 Bytes

Versions: 3

Compression:

Stored size: 488 Bytes

Contents

class Hyperion
  class ServerPool
    def initialize
      @free = []
      @in_use = []
    end

    def check_out
      s = @free.pop || FakeServer.new(next_port)
      @in_use.push(s)
      s
    end

    def check_in(s)
      @in_use.delete(s)
      @free.push(s)
    end

    def clear
      all = @free + @in_use
      all.each(&:teardown)
      @free = []
      @in_use = []
    end

    private

    def next_port
      @last_port ||= 9000
      @last_port += 1
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyperion_http-0.6.0 lib/hyperion_test/server_pool.rb
hyperion_http-0.5.0 lib/hyperion_test/server_pool.rb
hyperion_http-0.3.0 lib/hyperion_test/server_pool.rb