Parent

SSHKit::Backend::ConnectionPool

Constants

Entry

Attributes

idle_timeout[RW]

Public Class Methods

new() click to toggle source
# File lib/sshkit/backends/connection_pool.rb, line 11
def initialize
  self.idle_timeout = 30
  @mutex = Mutex.new
  @pool = {}
end

Public Instance Methods

checkin(entry) click to toggle source
# File lib/sshkit/backends/connection_pool.rb, line 25
def checkin(entry)
  entry.expires_at = Time.now + idle_timeout if idle_timeout
  @mutex.synchronize do
    @pool[entry.key] ||= []
    @pool[entry.key] << entry
  end
end
checkout(*new_connection_args, &block) click to toggle source
# File lib/sshkit/backends/connection_pool.rb, line 17
def checkout(*new_connection_args, &block)
  # Optimization: completely bypass the pool if idle_timeout is zero.
  key = new_connection_args.to_s
  return create_new_entry(new_connection_args, key, &block) if idle_timeout == 0

  find_live_entry(key) || create_new_entry(new_connection_args, key, &block)
end
flush_connections() click to toggle source
# File lib/sshkit/backends/connection_pool.rb, line 33
def flush_connections
  @mutex.synchronize { @pool.clear }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.