module Sequel::ArbitraryServers

def acquire(thread, server)

it, and cache it first by thread and then server.
If server is a hash, create a new connection for
def acquire(thread, server)
  if server.is_a?(Hash)
    sync{@allocated[thread] ||= {}}[server] = make_new(server)
  else
    super
  end
end

def owned_connection(thread, server)

avoid calling nil.[]
exist in the @allocated hash, so check for existence to
If server is a hash, the entry for it probably doesn't
def owned_connection(thread, server)
  if server.is_a?(Hash)
    if a = sync{@allocated[thread]}
      a[server]
    end
  else
    super
  end
end

def pick_server(server)

If server is a hash, return it directly.
def pick_server(server)
  if server.is_a?(Hash)
    server
  else
    super
  end
end

def release(thread, conn, server)

using that server, delete the server from the @allocated hash.
connections for that server. Additionally, if this was the last thread
If server is a hash, delete the thread from the allocated
def release(thread, conn, server)
  if server.is_a?(Hash)
    a = @allocated[thread]
    a.delete(server)
    @allocated.delete(thread) if a.empty?
    @disconnection_proc.call(conn) if @disconnection_proc
  else  
    super
  end
end