def exclusive(timeout = 30)
      give_up_at = Time.now + timeout if timeout
      while timeout.nil? || Time.now < give_up_at do
        if obtained_lock?
          return yield
        else
          # Randomizing sleep time may help reduce contention.
          sleep(rand(0.1..0.2))
        end
      end
    ensure
      release_lock unless transactional
    end
def exclusive(timeout = 30)
      give_up_at = Time.now + timeout if timeout
      while timeout.nil? || Time.now < give_up_at do
        if obtained_lock?
          return yield
        else
          # Randomizing sleep time may help reduce contention.
          sleep(rand(0.1..0.2))
        end
      end
    ensure
      release_lock unless transactional
    end
must be used within a transaction