123456789_123456789_123456789_123456789_123456789_

Class: Bundler::Fetcher::ConnectionPools::Pool

Relationships & Source Files
Inherits: Object
Defined in: lib/bundler/fetcher/connection_pools.rb

Overview

A fixed-size pool of connections to a single host, sharing the interface of Gem::Request::HTTPPool.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(connections, uri, proxy_uri, size) ⇒ Pool

[ GitHub ]

  
# File 'lib/bundler/fetcher/connection_pools.rb', line 18

def initialize(connections, uri, proxy_uri, size)
  @connections = connections
  @uri = uri
  @proxy_uri = proxy_uri
  @cert_files = connections.cert_files
  @queue = Thread::SizedQueue.new(size)
  size.times { @queue.push(nil) }
end

Instance Attribute Details

#cert_files (readonly)

[ GitHub ]

  
# File 'lib/bundler/fetcher/connection_pools.rb', line 16

attr_reader :cert_files, :proxy_uri

#proxy_uri (readonly)

[ GitHub ]

  
# File 'lib/bundler/fetcher/connection_pools.rb', line 16

attr_reader :cert_files, :proxy_uri

Instance Method Details

#checkin(connection)

[ GitHub ]

  
# File 'lib/bundler/fetcher/connection_pools.rb', line 31

def checkin(connection)
  @queue.push(connection)
end

#checkout

[ GitHub ]

  
# File 'lib/bundler/fetcher/connection_pools.rb', line 27

def checkout
  @queue.pop || @connections.build_connection(@uri, @proxy_uri)
end