module Que
  class PG < Adapter
    def initialize(pg)
      @pg    = pg
      @mutex = Mutex.new
    end

    def checkout
      @mutex.synchronize { yield @pg }
    end
  end
end

require 'monitor'

module Que
  class PG < Adapter
    def initialize(pg)
      @pg      = pg
      @monitor = Monitor.new
    end

    def checkout
      @monitor.synchronize { yield @pg }
    end
  end
end

Make sure that locking the bare PG connection is reentrant.
Make sure that locking the bare PG connection is reentrant.
