def transaction(force_sync = false, &block)
      # Ruby 1.9.3 does not support @mutex.owned?
      if @mutex.respond_to?(:owned?)
        force_sync = false if @mutex.locked? && @mutex.owned?
      else
        # If we allowed this in Ruby 1.9.3, it might possibly cause recursive
        # locking within the same thread.
        force_sync = false
      end
      if !force_sync && (@in_transaction || options[:without_mutex])
        block.call self
      else
        @mutex.synchronize do
          @in_transaction = true
          result = block.call
          @in_transaction = false
          result
        end
      end
    end
def transaction(force_sync = false, &block)
      # Ruby 1.9.3 does not support @mutex.owned?
      if @mutex.respond_to?(:owned?)
        force_sync = false if @mutex.locked? && @mutex.owned?
      else
        # If we allowed this in Ruby 1.9.3, it might possibly cause recursive
        # locking within the same thread.
        force_sync = false
      end
      if !force_sync && (@in_transaction || options[:without_mutex])
        block.call self
      else
        @mutex.synchronize do
          @in_transaction = true
          result = block.call
          @in_transaction = false
          result
        end
      end
    end
Wraps block execution in a thread-safe transaction