class Bundler::ConnectionPool::TimedStack

def pop(timeout = 0.5, options = {})

def pop(timeout = 0.5, options = {})
  options, timeout = timeout, 0.5 if Hash === timeout
  timeout = options.fetch :timeout, timeout
  deadline = current_time + timeout
  @mutex.synchronize do
    loop do
      raise Bundler::ConnectionPool::PoolShuttingDownError if @shutdown_block
      return fetch_connection(options) if connection_stored?(options)
      connection = try_create(options)
      return connection if connection
      to_wait = deadline - current_time
      raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available" if to_wait <= 0
      @resource.wait(@mutex, to_wait)
    end
  end
end